build(webpack): Fix the request of a dependency is an expression (#337)

* build(webpack): Fix the request of a dependency is an expression

Critical dependency: the request of a dependency is an expression

* style: Fix spaces after object literal braces
This commit is contained in:
Róbert Kiss
2017-07-05 18:35:56 +02:00
committed by László Monda
parent 1796e61f02
commit 67a55363da
3 changed files with 38 additions and 17 deletions

View File

@@ -1,10 +1,13 @@
var webpack = require("webpack"); const webpack = require("webpack");
var SvgStore = require('webpack-svgstore-plugin'); const SvgStore = require('webpack-svgstore-plugin');
var CopyWebpackPlugin = require('copy-webpack-plugin'); const CopyWebpackPlugin = require('copy-webpack-plugin');
var path = require('path'); const path = require('path');
var CommonsChunkPlugin = require("webpack/lib/optimize/CommonsChunkPlugin"); 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 = { module.exports = {
entry: { entry: {
@@ -19,7 +22,7 @@ module.exports = {
target: 'electron-renderer', target: 'electron-renderer',
externals: { externals: {
usb: 'usb', usb: 'usb',
'node-hid':'nodeHid' 'node-hid': 'nodeHid'
}, },
devtool: 'source-map', devtool: 'source-map',
resolve: { resolve: {
@@ -95,7 +98,12 @@ module.exports = {
}), }),
new CommonsChunkPlugin({ new CommonsChunkPlugin({
name: ['app', 'vendor', 'polyfills'] 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
)
] ]
} };

View File

@@ -0,0 +1,5 @@
const path = require('path');
module.exports.root = function root(dir, __path) {
return path.join(dir, __path);
};

View File

@@ -1,10 +1,13 @@
var webpack = require("webpack"); const webpack = require("webpack");
var SvgStore = require('webpack-svgstore-plugin'); const SvgStore = require('webpack-svgstore-plugin');
var CopyWebpackPlugin = require('copy-webpack-plugin'); const CopyWebpackPlugin = require('copy-webpack-plugin');
var path = require('path'); const path = require('path');
var CommonsChunkPlugin = require("webpack/lib/optimize/CommonsChunkPlugin"); 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); console.log(rootDir, __dirname);
module.exports = { module.exports = {
@@ -78,7 +81,12 @@ module.exports = {
}), }),
new CommonsChunkPlugin({ new CommonsChunkPlugin({
name: ['app', 'vendor', 'polyfills'] 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
)
] ]
} };