diff --git a/electron/src/webpack.config.js b/electron/src/webpack.config.js index 34ab4a2a..94b37ffb 100644 --- a/electron/src/webpack.config.js +++ b/electron/src/webpack.config.js @@ -1,10 +1,13 @@ -var webpack = require("webpack"); -var SvgStore = require('webpack-svgstore-plugin'); -var CopyWebpackPlugin = require('copy-webpack-plugin'); -var path = require('path'); -var CommonsChunkPlugin = require("webpack/lib/optimize/CommonsChunkPlugin"); +const webpack = require("webpack"); +const SvgStore = require('webpack-svgstore-plugin'); +const CopyWebpackPlugin = require('copy-webpack-plugin'); +const path = require('path'); +const CommonsChunkPlugin = require("webpack/lib/optimize/CommonsChunkPlugin"); +const ContextReplacementPlugin = require("webpack/lib/ContextReplacementPlugin"); -var rootDir = path.resolve(__dirname, '../'); +const webpackHelper = require('../../scripts/webpack-helper'); + +const rootDir = path.resolve(__dirname, '../'); module.exports = { entry: { @@ -19,7 +22,7 @@ module.exports = { target: 'electron-renderer', externals: { usb: 'usb', - 'node-hid':'nodeHid' + 'node-hid': 'nodeHid' }, devtool: 'source-map', resolve: { @@ -95,7 +98,12 @@ module.exports = { }), new CommonsChunkPlugin({ name: ['app', 'vendor', 'polyfills'] - }) + }), + new ContextReplacementPlugin( + // The (\\|\/) piece accounts for path separators in *nix and Windows + /angular(\\|\/)core(\\|\/)@angular/, + webpackHelper.root(__dirname, './src') // location of your src + ) ] -} +}; diff --git a/scripts/webpack-helper.js b/scripts/webpack-helper.js new file mode 100644 index 00000000..e906a7cc --- /dev/null +++ b/scripts/webpack-helper.js @@ -0,0 +1,5 @@ +const path = require('path'); + +module.exports.root = function root(dir, __path) { + return path.join(dir, __path); +}; diff --git a/web/src/webpack.config.js b/web/src/webpack.config.js index ceb7e1df..9d601014 100644 --- a/web/src/webpack.config.js +++ b/web/src/webpack.config.js @@ -1,10 +1,13 @@ -var webpack = require("webpack"); -var SvgStore = require('webpack-svgstore-plugin'); -var CopyWebpackPlugin = require('copy-webpack-plugin'); -var path = require('path'); -var CommonsChunkPlugin = require("webpack/lib/optimize/CommonsChunkPlugin"); +const webpack = require("webpack"); +const SvgStore = require('webpack-svgstore-plugin'); +const CopyWebpackPlugin = require('copy-webpack-plugin'); +const path = require('path'); +const CommonsChunkPlugin = require("webpack/lib/optimize/CommonsChunkPlugin"); +const ContextReplacementPlugin = require("webpack/lib/ContextReplacementPlugin"); -var rootDir = path.resolve(__dirname, '../'); +const webpackHelper = require('../../scripts/webpack-helper'); + +const rootDir = path.resolve(__dirname, '../'); console.log(rootDir, __dirname); module.exports = { @@ -78,7 +81,12 @@ module.exports = { }), new CommonsChunkPlugin({ name: ['app', 'vendor', 'polyfills'] - }) + }), + new ContextReplacementPlugin( + // The (\\|\/) piece accounts for path separators in *nix and Windows + /angular(\\|\/)core(\\|\/)@angular/, + webpackHelper.root(__dirname, './src') // location of your src + ) ] -} +};