const path = require('path'); const HtmlWebpackPlugin = require('html-webpack-plugin'); const { CleanWebpackPlugin } = require('clean-webpack-plugin'); module.exports = { mode: 'development', entry: { app: './src/index.js', print: './src/print.js' }, output: { filename: '[name].bundle.js', path: path.resolve(__dirname, 'dist'), // publicPath: '/' }, devtool: 'inline-source-map', devServer: { contentBase: './dist', open: false, //自动打开浏览器 compress: true, //启动Gzip压缩 port: 8080, //端口号8080 quiet: true //静默打开 }, plugins: [ new CleanWebpackPlugin(), new HtmlWebpackPlugin({ title: 'Output Management' }) ], module: { rules: [{ test: /\.css$/, use: ['style-loader', 'css-loader'] }, { test: /\.(png|jpg|svg|gif)$/, use: ['file-loader'] }, { test: /\.(woff|woff2|eot|ttf|otf)$/, use: ['file-loader'] }, { test: /\.(csv|tsv)$/, use: ['csv-loader'] }, { test: /\.xml$/, use: ['xml-loader'] }] } };
这样,报错问题就解决啦。