在寫組件的時(shí)候,會(huì)區(qū)分開發(fā)和生產(chǎn)環(huán)境,在webpack中使用插件html-webpack-plugin實(shí)現(xiàn)動(dòng)態(tài)生成html文件,使用node 的express搭建一個(gè)服務(wù)器,webpack的代碼如下:生產(chǎn)環(huán)境下:config.plugins = [ // 提取css為單文件
new ExtractTextPlugin("../[name].[contenthash].css"), new HtmlWebpackPlugin({
filename: '../index.html', template: path.resolve(__dirname, '../src/index.html'),
inject: true
})
];開發(fā)環(huán)境下:config.plugins = [ new webpack.optimize.OccurenceOrderPlugin(), new webpack.HotModuleReplacementPlugin(), new webpack.NoErrorsPlugin(), new HtmlWebpackPlugin({ filename: 'src/index.html', template: path.resolve(__dirname, '../src/index.html'), inject: true })];請(qǐng)教下: HtmlWebpackPlugin中的filename 為什么不是一樣的,最后訪問localhost:8080必須加上/src才能看到對(duì)應(yīng)的頁面,是什么原因??
請(qǐng)教下webpack+node express的使用
楊__羊羊
2018-10-09 17:40:32