Last active
May 7, 2019 14:57
-
-
Save timse/ed3b09536626fd98b6d08c444213498e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require('path'); | |
const webpack = require('webpack'); | |
const NameAllModulesPlugin = require('name-all-modules-plugin'); | |
module.exports = { | |
entry: { | |
main: './src/foo', | |
other: './src/foo-two', | |
vendor: ['preact'] | |
}, | |
output: { | |
path: path.join(__dirname, 'dist'), | |
filename: '[name].[chunkhash].js', | |
}, | |
externals: { | |
jquery: 'jQuery' | |
}, | |
plugins: [ | |
new webpack.NamedModulesPlugin(), | |
new webpack.NamedChunksPlugin((chunk) => { | |
if (chunk.name) { | |
return chunk.name; | |
} | |
return chunk.modules.map(m => path.relative(m.context, m.request)).join("_"); | |
}), | |
new webpack.optimize.CommonsChunkPlugin({ | |
name: 'vendor', | |
minChunks: Infinity | |
}), | |
new webpack.optimize.CommonsChunkPlugin({ | |
name: 'runtime' | |
}), | |
new NameAllModulesPlugin(), | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
path.relative(m.context, m.request)
alone won't convertm.request
to relative path since loaders use abs path, e.g./abs path/to-string!/abs path/css-loader
.We may need to split and convert them to relative path too.
e.g.