Mar*_*S82 2 webpack vue.js vue-cli
我想重命名由index.html生成的npm run build。我在webpack配置中找不到任何内容。
我还在vue.config.js这里创建了一个描述:https : //github.com/vuejs/vue-cli/tree/dev/docs/config
module.exports = {
pages: {
index: {
filename: 'dapp.html',
}
}
};
Run Code Online (Sandbox Code Playgroud)
但是输出文件仍然 index.html
你可以使用
module.exports = {
indexPath: 'index_bundled.html'
}
Run Code Online (Sandbox Code Playgroud)
作为 vue cli 默认选项来更改文件
由于您正在创建vue.config.js,因此我假设您正在使用vue-cli 3.0。
鉴于您应该在vue.config.js上添加以下行。
module.exports = {
// modify the location of the generated HTML file.
// make sure to do this only in production.
chainWebpack: (config) => {
if (process.env.NODE_ENV === 'production') {
config.plugin('html').tap((opts) => {
opts[0].filename = './dist/dapp.html';
return opts;
});
}
},
};
Run Code Online (Sandbox Code Playgroud)
Vue的创建者已在github https://github.com/yyx990803/laravel-vue-cli-3上设置了一个laravel-vue-cli-3示例,您可以在其中查看
如果您正在使用vue Webpack模板,则在config文件夹中有一个index.js文件。在module.exports内部,您将找到以下可以设置输出的位置:
...
build: {
// Template for index.html
index: path.resolve(__dirname, './dist/index.html'),
...
},
Run Code Online (Sandbox Code Playgroud)
只需将dapp.html更改为index.html即可,这应该可以工作。
如果您使用的是webpack模板,则可以在http://vuejs-templates.github.io/webpack/backend.html上查看更多详细信息。
| 归档时间: |
|
| 查看次数: |
2818 次 |
| 最近记录: |