about summary refs log tree commit diff
path: root/config/webpack
diff options
context:
space:
mode:
authorNaouak <tardiel@gmail.com>2017-05-30 15:30:59 +0200
committerEugen Rochko <eugen@zeonfederated.com>2017-05-30 15:30:59 +0200
commit499cc7b803fe6f9bddf0155b2e80cbb0fba4fb6d (patch)
tree28633befc89640441c8ab91d2d41805162a5be30 /config/webpack
parent7db98aa70e44c922bd13d72e78e0ae94826ad29f (diff)
Fix webpack building on Windows (#3426)
* Path should not be constructed manually. Use path.join to ensure compatibility.

* Path should not be constructed manually. Use path.join to ensure compatibility.

* Fix regexp.

* Fix my own stupidity.
I forgot to check outside my test script the regexp...
Diffstat (limited to 'config/webpack')
-rw-r--r--config/webpack/shared.js11
1 files changed, 6 insertions, 5 deletions
diff --git a/config/webpack/shared.js b/config/webpack/shared.js
index 12e05dec2..1744353f7 100644
--- a/config/webpack/shared.js
+++ b/config/webpack/shared.js
@@ -4,7 +4,7 @@
 /* eslint import/no-dynamic-require: 0 */
 
 const webpack = require('webpack');
-const { basename, dirname, join, relative, resolve } = require('path');
+const { basename, dirname, join, relative, resolve, sep } = require('path');
 const { sync } = require('glob');
 const ExtractTextPlugin = require('extract-text-webpack-plugin');
 const ManifestPlugin = require('webpack-manifest-plugin');
@@ -21,7 +21,7 @@ module.exports = {
     (map, entry) => {
       const localMap = map;
       let namespace = relative(join(paths.source, paths.entry), dirname(entry));
-      if (namespace === '../../../tmp/packs') {
+      if (namespace === join('..', '..', '..', 'tmp', 'packs')) {
         namespace = ''; // generated by generateLocalePacks.js
       }
       localMap[join(namespace, basename(entry, extname(entry)))] = resolve(entry);
@@ -47,14 +47,15 @@ module.exports = {
     new webpack.optimize.CommonsChunkPlugin({
       name: 'common',
       minChunks: (module, count) => {
-        if (module.resource && /node_modules\/react-intl/.test(module.resource)) {
+        const reactIntlPathRegexp = new RegExp(`node_modules\\${sep}react-intl`);
+        if (module.resource && reactIntlPathRegexp.test(module.resource)) {
           // skip react-intl because it's useless to put in the common chunk,
           // e.g. because "shared" modules between zh-TW and zh-CN will never
           // be loaded together
           return false;
         }
-
-        if (module.resource && /node_modules\/font-awesome/.test(module.resource)) {
+        const fontAwesomePathRegexp = new RegExp(`node_modules\\${sep}font-awesome`);
+        if (module.resource && fontAwesomePathRegexp.test(module.resource)) {
           // extract vendor css into common module
           return true;
         }