Closed jknight12882 closed 7 years ago
Config file for reference
import webpack from 'webpack';
import path from 'path';
import ManifestPlugin from 'webpack-manifest-plugin';
import locales from './locales';
const common = (locale, cache) => ({
// verbose: true,
devtool: 'source-map',
entry: {
[`common_${locale}`]: [
...
]
},
output: {
filename: '[name]-[chunkhash].js',
library: 'common',
path: path.resolve(__dirname, '../dist/public/js')
},
resolve: {
root: path.resolve(__dirname, '../src'),
modulesDirectories: ['node_modules'],
extensions: ['', '.json', '.js']
},
plugins: [
new ManifestPlugin({
cache,
fileName: 'common-manifest.json'
}),
new webpack.DllReferencePlugin({
context: path.resolve(__dirname, '..'),
manifest: require(path.resolve(__dirname, '../.build/dll/react-manifest.json'))
}),
new webpack.DllPlugin({
path: path.resolve(__dirname, '../.build/dll/[name]-manifest.json'),
name: 'common',
context: path.resolve(__dirname, '..')
})
]
});
const dev = () => {
const cache = { };
return locales.map(locale => common(locale, cache));
};
const prod = () => {
const cache = { };
return locales.map(locale => {
const config = Object.assign(common(locale, cache), {
devtool: 'hidden-source-map'
});
config.plugins.push(
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production')
}),
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin({
sourceMap: true,
compress: {
warnings: false
}
})
);
return config;
});
};
export default (process.env.NODE_ENV === 'production') ? prod : dev;
I'm also occasionally having the same issue. One build will be fine, the next will have a bad closing brace in the middle of the list.
I know it won't be easy (and I'm not sure if feasible... :/), but it would be a great help if you could send me a failing PR reproducing the issue
I'm reopening this one as I'm reverting the earlier fix, as it was causing another issue...
So i now understand better how this issue is happening:
It's caused by this: https://github.com/webpack/webpack/blob/ef6ab6820a74db730cfec6fd419d2c211d62c0bd/lib/Compiler.js#L343
What's happening, is that webpack is writing the same file multiple times
To prevent that, we need to use https://github.com/mafintosh/mutexify to lock: https://github.com/danethurber/webpack-manifest-plugin/blob/1d691af97b955cc8c1c8cd5b684e54a81c7d0a3d/lib/plugin.js#L161 and release it on after-emit
event
I will now focus on 2.x release, but if anyone feels like it, they can send us a PR :)
In multi compiler mode with a shared cache, I am getting the following mangled output.
This is inconsistent, sometimes the file is correct, sometimes it is as above