我有以下vue.config.js
:
module.exports = {
filenameHashing: false,
productionSourceMap: false,
outputDir: '../vuejs/',
configureWebpack: {
devtool: 'source-map',
output: {
filename: '[name].js'
}
},
pages: {
feature1: {
entry: 'src/f1.js',
template: 'public/feature.html',
filename: 'index1.html',
title: 'Feature 1',
chunks: ['chunk-vendors', 'chunk-common', 'feature1']
},
feature2: {
entry: 'src/f2.js',
template: 'public/feature.html',
filename: 'index2.html',
title: 'Feature 2',
chunks: ['chunk-vendors', 'chunk-common', 'feature2']
}
}
}
在npm run build
上它会生成:
index1.html
index2.html
feature1.js
feature2.js
js/chunk-vendors.js
在dist文件夹(../vuejs/
)
如何更改配置,以便将文件chunk-vendors.js
放在根文件夹中(feature1.js
和feature2.js
所在的位置)。
P.S。 :(额外的问题)我实际上不需要html文件,因为我将vue.js *.js
嵌入到现有应用程序中。我可以禁止生成html文件吗?
答案 0 :(得分:0)
您可以定义一个明确的chunkFilename
;例如:
module.exports = {
outputDir: 'my/custom/build/path/',
configureWebpack: (config) => {
config.output.filename = '[name].[hash:8]js';
config.output.chunkFilename = '[name].[hash:8].js';
}
}
应该生成类似以下内容的
my/custom/build/path/app.216ad62b.js
my/custom/build/path/app.216ad62b.js.map
my/custom/build/path/chunk-vendors.6f85144f.js
my/custom/build/path/chunk-vendors.6f85144f.js.map
希望这会有所帮助:)