-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
36 lines (34 loc) · 1021 Bytes
/
webpack.config.js
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
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
module.exports = {
entry: './src/index.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'app.bundle.js'
},
module: {
rules: [
{test: /\.(js|jsx)$/, exclude: /node_modules/, use: 'babel-loader'},
{test: /\.css$/, use: ['style-loader', 'css-loader']},
{test: /\.(jpg|gif|png|webp|ico)$/, use: 'url-loader'}, // 图片只需要这一个loader即可
{test: /\.(ttf|eot)$/, use: 'file-loader'},
{test: /\.html$/, use: 'html-loader'},// 处理HTML中的图片引用
]
},
plugins: [
new HtmlWebpackPlugin({
template: './src/index.html',
favicon: './src/pelli.ico',
title: 'webpack极简配置'
}),
new webpack.HotModuleReplacementPlugin(), // 开启服务器热加载,更新源代码会自动刷新浏览器
],
devServer: {
contentBase: path.join(__dirname, 'dist'),
compress: true,
host: 'localhost',
port: 3333,
hot: true
}
};