在寫組件的時候,會區分開發和生產環境,在webpack中使用插件html-webpack-plugin實現動態生成html文件,使用node 的express搭建一個服務器,webpack的代碼如下:生產環境下:config.plugins = [ // 提取css為單文件
new ExtractTextPlugin("../[name].[contenthash].css"), new HtmlWebpackPlugin({
filename: '../index.html', template: path.resolve(__dirname, '../src/index.html'),
inject: true
})
];開發環境下: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 })];請教下: HtmlWebpackPlugin中的filename 為什么不是一樣的,最后訪問localhost:8080必須加上/src才能看到對應的頁面,是什么原因??
請教下webpack+node express的使用
楊__羊羊
2018-10-09 17:40:32