Skip to content

TagSpaces is an offline, open source, document manager with tagging support

correcting webpack and pro integration

Ilian Sapundshievef0ca8020255
diff --git a/app/main.dev.ts b/app/main.dev.ts
index fadc5da4f..40e85b065 100644
--- a/app/main.dev.ts
+++ b/app/main.dev.ts
@@ -45,7 +45,7 @@ process.argv.forEach((arg, count) => {
} else if (arg.indexOf('-psn') >= 0) {
// ignoring the -psn process serial number parameter on MacOS by double click
arg = '';
- } else if (arg === 'babel-register' || arg === '.' || count === 0) {
+ } else if (arg === './app/main.dev.babel.js' || arg === '.' || count === 0) {
// ignoring the first argument
// Ignore these argument
} else if (arg.length > 2) {
diff --git a/app/services/platform-io.ts b/app/services/platform-io.ts
index 7def94697..5dbddd05f 100644
--- a/app/services/platform-io.ts
+++ b/app/services/platform-io.ts
@@ -16,25 +16,11 @@
*
*/
-import AppConfig from '../config';
import { Pro } from '../pro';
-import ElectronIO from './electron-io';
-import WebDAVIO from './electron-io';
-
-let nativeAPI: any = new ElectronIO();
-// let nativeAPI: any = new WebDAVIO();
-
-// let nativeAPI: any = {};
-// if (AppConfig.isElectron) {
-// nativeAPI = require('./electron-io');
-// } else if (AppConfig.isWeb) {
-// // const WebDAVIO = require('./webdav-io');
-// // nativeAPI = new WebDAVIO();
-// } else if (AppConfig.isCordovaAndroid || AppConfig.isCordovaiOS) {
-// // const CordovaIO = require('./cordova-io');
-// // nativeAPI = new CordovaIO();
-// }
+// @ts-ignore
+import platformIO from './_PLATFORMIO_';
+let nativeAPI: any = new platformIO();
let objectStoreAPI;
export default class PlatformIO {
diff --git a/configs/webpack.config.main.prod.babel.js b/configs/webpack.config.main.prod.babel.js
index 058f02f1c..d1369591b 100644
--- a/configs/webpack.config.main.prod.babel.js
+++ b/configs/webpack.config.main.prod.babel.js
@@ -12,6 +12,8 @@ import CheckNodeEnv from '../internals/scripts/CheckNodeEnv';
CheckNodeEnv('production');
+const targetPlatform = 'electron-io'; // electron-io | webdav-io | cordova-io | process.env.APP_TARGET ||
+
export default merge.smart(baseConfig, {
devtool: 'source-map',
@@ -45,6 +47,15 @@ export default merge.smart(baseConfig, {
openAnalyzer: process.env.OPEN_ANALYZER === 'true'
}),
+ new webpack.NormalModuleReplacementPlugin(/(.*)_PLATFORMIO_(\.*)/, function(
+ resource
+ ) {
+ resource.request = resource.request.replace(
+ /_PLATFORMIO_/,
+ `${targetPlatform}`
+ );
+ }),
+
/**
* Create global constants which can be configured at compile time.
*
diff --git a/configs/webpack.config.renderer.dev.babel.js b/configs/webpack.config.renderer.dev.babel.js
index 0d64ff626..1f111b894 100644
--- a/configs/webpack.config.renderer.dev.babel.js
+++ b/configs/webpack.config.renderer.dev.babel.js
@@ -18,6 +18,8 @@ import CheckNodeEnv from '../internals/scripts/CheckNodeEnv';
CheckNodeEnv('development');
+const targetPlatform = 'electron-io'; // electron-io | webdav-io | cordova-io | process.env.APP_TARGET ||
+
const port = process.env.PORT || 1212;
const publicPath = `http://localhost:${port}/dist`;
const dll = path.join(__dirname, '..', 'dll');
@@ -204,6 +206,15 @@ export default merge.smart(baseConfig, {
multiStep: true
}),
+ new webpack.NormalModuleReplacementPlugin(/(.*)_PLATFORMIO_(\.*)/, function(
+ resource
+ ) {
+ resource.request = resource.request.replace(
+ /_PLATFORMIO_/,
+ `${targetPlatform}`
+ );
+ }),
+
new webpack.NoEmitOnErrorsPlugin(),
/**
diff --git a/configs/webpack.config.renderer.dev.dll.babel.js b/configs/webpack.config.renderer.dev.dll.babel.js
index f80e40fa0..4fc7dde51 100644
--- a/configs/webpack.config.renderer.dev.dll.babel.js
+++ b/configs/webpack.config.renderer.dev.dll.babel.js
@@ -13,6 +13,8 @@ import CheckNodeEnv from '../internals/scripts/CheckNodeEnv';
CheckNodeEnv('development');
+const targetPlatform = 'electron-io'; // electron-io | webdav-io | cordova-io | process.env.APP_TARGET ||
+
const dist = path.join(__dirname, '..', 'dll');
export default merge.smart(baseConfig, {
@@ -61,6 +63,15 @@ export default merge.smart(baseConfig, {
NODE_ENV: 'development'
}),
+ new webpack.NormalModuleReplacementPlugin(/(.*)_PLATFORMIO_(\.*)/, function(
+ resource
+ ) {
+ resource.request = resource.request.replace(
+ /_PLATFORMIO_/,
+ `${targetPlatform}`
+ );
+ }),
+
new webpack.LoaderOptionsPlugin({
debug: true,
options: {
diff --git a/configs/webpack.config.renderer.prod.babel.js b/configs/webpack.config.renderer.prod.babel.js
index 2928984ed..3ee963d58 100644
--- a/configs/webpack.config.renderer.prod.babel.js
+++ b/configs/webpack.config.renderer.prod.babel.js
@@ -12,6 +12,8 @@ import TerserPlugin from 'terser-webpack-plugin';
import baseConfig from './webpack.config.base';
import CheckNodeEnv from '../internals/scripts/CheckNodeEnv';
+const targetPlatform = 'electron-io'; // electron-io | webdav-io | cordova-io | process.env.APP_TARGET ||
+
CheckNodeEnv('production');
export default merge.smart(baseConfig, {
devtool: 'source-map',
@@ -207,6 +209,15 @@ export default merge.smart(baseConfig, {
NODE_ENV: 'production'
}),
+ new webpack.NormalModuleReplacementPlugin(/(.*)_PLATFORMIO_(\.*)/, function(
+ resource
+ ) {
+ resource.request = resource.request.replace(
+ /_PLATFORMIO_/,
+ `${targetPlatform}`
+ );
+ }),
+
new MiniCssExtractPlugin({
filename: 'style.css'
}),
diff --git a/configs/webpack.config.web.prod.babel.js b/configs/webpack.config.web.prod.babel.js
index 1bf43c70a..f5f66106c 100644
--- a/configs/webpack.config.web.prod.babel.js
+++ b/configs/webpack.config.web.prod.babel.js
@@ -12,6 +12,8 @@ import TerserPlugin from 'terser-webpack-plugin';
import baseConfig from './webpack.config.base';
import CheckNodeEnv from '../internals/scripts/CheckNodeEnv';
+const targetPlatform = 'webdav-io'; // electron-io | webdav-io | cordova-io | process.env.APP_TARGET ||
+
CheckNodeEnv('production');
export default merge.smart(baseConfig, {
devtool: 'source-map',
@@ -165,7 +167,7 @@ export default merge.smart(baseConfig, {
// Text files
{
test: /\.(txt)$/,
- use: 'raw-loader'
+ use: 'file-loader'
},
// Common Image Formats
{
@@ -213,6 +215,15 @@ export default merge.smart(baseConfig, {
filename: 'style.css'
}),
+ new webpack.NormalModuleReplacementPlugin(/(.*)_PLATFORMIO_(\.*)/, function(
+ resource
+ ) {
+ resource.request = resource.request.replace(
+ /_PLATFORMIO_/,
+ `${targetPlatform}`
+ );
+ }),
+
new BundleAnalyzerPlugin({
analyzerMode:
process.env.OPEN_ANALYZER === 'true' ? 'server' : 'disabled',
diff --git a/configs/webpack.config.worker.prod.babel.js b/configs/webpack.config.worker.prod.babel.js
index fe8088c63..c7599ba36 100644
--- a/configs/webpack.config.worker.prod.babel.js
+++ b/configs/webpack.config.worker.prod.babel.js
@@ -12,6 +12,8 @@ import TerserPlugin from 'terser-webpack-plugin';
import baseConfig from './webpack.config.base';
import CheckNodeEnv from '../internals/scripts/CheckNodeEnv';
+const targetPlatform = 'electron-io'; // electron-io | webdav-io | cordova-io | process.env.APP_TARGET ||
+
CheckNodeEnv('production');
export default merge.smart(baseConfig, {
devtool: 'source-map',
@@ -207,6 +209,15 @@ export default merge.smart(baseConfig, {
NODE_ENV: 'production'
}),
+ new webpack.NormalModuleReplacementPlugin(/(.*)_PLATFORMIO_(\.*)/, function(
+ resource
+ ) {
+ resource.request = resource.request.replace(
+ /_PLATFORMIO_/,
+ `${targetPlatform}`
+ );
+ }),
+
new MiniCssExtractPlugin({
filename: 'style.css'
}),
diff --git a/tsconfig.json b/tsconfig.json
index 8500c9079..faee060bc 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -1,11 +1,11 @@
{
"compilerOptions": {
- "allowJs": false,
- "target": "es5",
+ "allowJs": true,
+ "target": "esnext", // es5
"baseUrl": "./",
"rootDir": "./",
"jsx": "react",
- "module": "esnext",
+ "module": "esnext", // esnext, commonjs
"moduleResolution": "node",
"noUnusedLocals": false,
"allowSyntheticDefaultImports": true,
@@ -13,12 +13,17 @@
"sourceMap": true,
"skipLibCheck": true,
"resolveJsonModule": true,
- "lib": ["es2015", "dom"],
+ "lib": ["esnext", "dom"], // "lib": ["es2015", "dom"],
"paths": {
"-/*": ["app/*"]
}
},
- "include": ["app/**/*.ts", "app/**/*.tsx"]
+ "include": [
+ "app/**/*.ts",
+ "app/**/*.tsx"
+ // "app/node_modules/@tagspaces/pro/**/*.ts",
+ // "app/node_modules/@tagspaces/pro/**/*.tsx"
+ ]
// "exclude": [
// "node_modules",
// "**/node_modules/*",