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...
This commit is contained in:
		| @ -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; | ||||
|         } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user