webpack4 大纲概论-output(三)
https://v4.webpack.js.org/concepts/output/
output
编译后的输入文件夹,可以有多个配置入口,但只有一个出口配置
module.exports = { output: { filename: 'bundle.js', } };
多入口:
module.exports = { entry: { app: './src/app.js', search: './src/search.js' }, output: { filename: '[name].js', path: __dirname + '/dist' } };
更复杂的使用cdn和hash:
module.exports = { //... output: { path: '/home/proj/cdn/assets/[hash]', publicPath: 'https://cdn.example.com/assets/[hash]/' } };
编译时不知道输出文件的最终公共路径,可设置为空,然后通过入口文件中的__webpack_public_path__动态配置:
__webpack_public_path__ = myRuntimePublicPath;

浙公网安备 33010602011771号