1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
| const HtmlWebpackPlugin = require('html-webpack-plugin'); const { resolve } = require('path');
module.exports = { entry: './src/js/index.js', output: { filename: 'js/index.js', path: resolve(__dirname, 'prod'), }, mode: 'production', module: { rules: [ { test: /\.less$/, use: ['style-loader', 'css-loader', 'less-loader'], }, { test: /\.css$/, use: ['style-loader', 'css-loader'], }, { test: /\.(png|gif|jpg)$/, loader: 'url-loader', options: { outputPath: 'img', limit: 8 * 1024, name: '[hash:10].[ext]', esModule: false, }, }, { test: /\.html$/, loader: 'html-loader', options: { esModule: false, }, }, { exclude: /\.(less|css|jpg|png|gif|html|js)$/, loader: 'file-loader', options: { outputPath: 'media', name: '[hash:10].[ext]', }, }, ], }, plugins: [ new HtmlWebpackPlugin({ template: './src/index.html', }), ], devServer: { contentBase: resolve(__dirname, 'build'), port: 3000, compress: true, open: true, }, };
|