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:
parent
7db98aa70e
commit
499cc7b803
1 changed files with 6 additions and 5 deletions
|
@ -4,7 +4,7 @@
|
||||||
/* eslint import/no-dynamic-require: 0 */
|
/* eslint import/no-dynamic-require: 0 */
|
||||||
|
|
||||||
const webpack = require('webpack');
|
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 { sync } = require('glob');
|
||||||
const ExtractTextPlugin = require('extract-text-webpack-plugin');
|
const ExtractTextPlugin = require('extract-text-webpack-plugin');
|
||||||
const ManifestPlugin = require('webpack-manifest-plugin');
|
const ManifestPlugin = require('webpack-manifest-plugin');
|
||||||
|
@ -21,7 +21,7 @@ module.exports = {
|
||||||
(map, entry) => {
|
(map, entry) => {
|
||||||
const localMap = map;
|
const localMap = map;
|
||||||
let namespace = relative(join(paths.source, paths.entry), dirname(entry));
|
let namespace = relative(join(paths.source, paths.entry), dirname(entry));
|
||||||
if (namespace === '../../../tmp/packs') {
|
if (namespace === join('..', '..', '..', 'tmp', 'packs')) {
|
||||||
namespace = ''; // generated by generateLocalePacks.js
|
namespace = ''; // generated by generateLocalePacks.js
|
||||||
}
|
}
|
||||||
localMap[join(namespace, basename(entry, extname(entry)))] = resolve(entry);
|
localMap[join(namespace, basename(entry, extname(entry)))] = resolve(entry);
|
||||||
|
@ -47,14 +47,15 @@ module.exports = {
|
||||||
new webpack.optimize.CommonsChunkPlugin({
|
new webpack.optimize.CommonsChunkPlugin({
|
||||||
name: 'common',
|
name: 'common',
|
||||||
minChunks: (module, count) => {
|
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,
|
// 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
|
// e.g. because "shared" modules between zh-TW and zh-CN will never
|
||||||
// be loaded together
|
// be loaded together
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
const fontAwesomePathRegexp = new RegExp(`node_modules\\${sep}font-awesome`);
|
||||||
if (module.resource && /node_modules\/font-awesome/.test(module.resource)) {
|
if (module.resource && fontAwesomePathRegexp.test(module.resource)) {
|
||||||
// extract vendor css into common module
|
// extract vendor css into common module
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue