-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.dev.js
96 lines (91 loc) · 2.7 KB
/
webpack.config.dev.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/**
* @author [email protected]
* @date 2017/8/22
*/
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
module.exports = {
entry: [
'babel-polyfill',
'./src/index.client.js'
],
target: 'web',
output: {
filename: '[name].[hash:4].js',
chunkFilename: '[name].[chunkhash:4].js',
path: path.resolve(__dirname, 'dist'),
publicPath: '/'
},
module: {
rules: [
//JS和JSX加载
{
test: /\.jsx?$/,
use: {
loader: 'babel-loader',
},
exclude: path.resolve(__dirname, 'node_modules', 'animated')
},
{
test: /\/pages\/.*\.jsx?/, //pages下的都用bundle-loader加载
use: ['bundle-loader?lazy','babel-loader']
},
//css加载
// {
// test: /\.css$/,
// use: [ 'style-loader', 'css-loader' ],
// include: path.resolve('./src')
// },
//图片文件加载
{
test: /\.png|jpe?g|gif|svg(\?.*)?/,
use: {
loader: "url-loader",//引用图片的格式,通过query来指定
query: {
name: 'img/[name].[hash:4].[ext]',
limit: 1000 //小于这个则会通过dataURI引用
}
},
include: path.resolve('./src')
},
//音频视频文件加载
{
test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
use: {
loader: 'url-loader',
options: {
name: 'media/[name].[hash:4].[ext]'
}
}
},
//字体加载
{
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
use: {
loader: 'url-loader',
options: {
name: 'fonts/[name].[hash:4].[ext]'
}
}
}
]
},
plugins: [
new HtmlWebpackPlugin({template: './src/index.html'}),
new webpack.HotModuleReplacementPlugin(),
new webpack.DefinePlugin({
"process.env": {
NODE_ENV: JSON.stringify("development")
}
}),
],
devServer: {
hot: true, //打开 HMR
contentBase: path.join(__dirname, "dist"),
compress: true,
host: '10.194.11.62',
port: 9000,
// host: "192.168.0.18"
}
};