$_> npm i -D file-loader html-loader
// webpack.config.js
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: {
index: './src/index.js',
util: './src/util.js',
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].bundle.js',
},
module: {
rules: [{
test: /\.(css)$/,
use: ['style-loader','css-loader']
},{
test: /\.(jpeg|png|jpg)$/,
use: {loader:'file-loader',
options: {
outputPath: 'assets/imgs/',
}
}
},{
test: /\.(html)$/,
use: {loader: 'html-loader'}
}]
},
plugins: [
new HtmlWebpackPlugin({
filename: 'index.html',
template: './src/html/index.html',
inject: 'body',
chunks: ['index']
})
],
mode: 'development'
};
捕获.JPG
网友评论