本文共 2017 字,大约阅读时间需要 6 分钟。
???html-webpack-plugin???????????????????????ejs???????????????????html-loader????????????????
html-webpack-plugin??????html????????????????html-loader????????????
const { CleanWebpackPlugin } = require('clean-webpack-plugin');const UglifyJsPlugin = require('uglifyjs-webpack-plugin');const HtmlWebpackPlugin = require('html-webpack-plugin');module.exports = { entry: { index: './src/index.js', demo: './src/demo.js', main: './src/main.js' }, output: { path: path.resolve(__dirname, './dist'), filename: 'js/[name].js' }, mode: 'development', plugins: [ new CleanWebpackPlugin(), new HtmlWebpackPlugin({ chunks: ['main', 'index'], template: 'index.html', filename: 'index.html' }), new UglifyJsPlugin({ exclude: /\/main/ }) ], module: { rules: [ { test: /\.(png|jpg|gif)$/, use: [{ loader: 'url-loader', options: { esModule: false } }] }, { test: /\.css$/, loader: 'style-loader' }, { test: /\.css$/, loader: 'css-loader' }, { test: /\.html$/, loader: 'html-loader' } ] }};
?????????????html-webpack-plugin?html-loader??????????????ejs?????????
转载地址:http://jead.baihongyu.com/