你項目中使用Webpack作爲一個模塊捆綁 - 它注入到app.js的index.html
獲得非變醜束,編輯的WebPack設置是這樣的:
評論調用插件uglifyjs-的WebPack-插件在構建/webpack.prod.conf.js
之前
...
plugins: [
// http://vuejs.github.io/vue-loader/en/workflow/production.html
new webpack.DefinePlugin({
'process.env': env
}),
new UglifyJsPlugin({
uglifyOptions: {
compress: {
warnings: false
}
},
sourceMap: config.build.productionSourceMap,
parallel: true
}),
// extract css into its own file
new ExtractTextPlugin({
filename: utils.assetsPath('css/[name].[contenthash].css'),
// set the following option to `true` if you want to extract CSS from
// codesplit chunks into this main css file as well.
// This will result in *all* of your app's CSS being loaded upfront.
allChunks: false,
})
...
後
...
plugins: [
// http://vuejs.github.io/vue-loader/en/workflow/production.html
new webpack.DefinePlugin({
'process.env': env
}),
// new UglifyJsPlugin({
// uglifyOptions: {
// compress: {
// warnings: false
// }
// },
// sourceMap: config.build.productionSourceMap,
// parallel: true
// }),
// extract css into its own file
new ExtractTextPlugin({
filename: utils.assetsPath('css/[name].[contenthash].css'),
// set the following option to `true` if you want to extract CSS from
// codesplit chunks into this main css file as well.
// This will result in *all* of your app's CSS being loaded upfront.
allChunks: false,
}),
...
此外,如果你想改變的index.html的名稱foo.html輸入文件,你可以在這裏做到這一點:
線68 構建/的WebPack .prod.conf.js變化
template: 'foo.html',
'EL: 「#APP」'告訴Vue公司與app'的'了'id'實例化Vue公司的'div'。我希望你發佈的內容有錯誤,它不是'class =「app」',它的'id =「app」'。 – Bert
是的。你是對的。改變了那個錯誤。但我試圖從頭開始寫自己的webpack配置。然而,我不知道哪一行代碼是負責** el:「#app」告訴Vue實例化應用程序的ID的div上的Vue **我在哪裏可以在模板中找到它? – mingsterism
這是您的問題中發佈的第一段代碼中的第二行。如果你想寫自己的webpack.config.js,我建議你從'webpack-simple'模板開始。從中可以更容易地瞭解發生了什麼。 – Bert