-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathwebpack.dev.config.js
102 lines (97 loc) · 2.84 KB
/
webpack.dev.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
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
97
98
99
100
101
102
var path = require('path');
const webpack = require("webpack");
var precss = require('precss');
var autoprefixer = require('autoprefixer');
module.exports = {
entry: path.resolve(__dirname, 'app/index.js'),
output: {
path: path.join(__dirname, '/public'),
publicPath: '/',
filename: 'bundle.js',
},
plugins: [
new webpack.NamedModulesPlugin(),
// prints more readable module names in the browser console on HMR updates
new webpack.NoEmitOnErrorsPlugin(),
// do not emit compiled assets that include errors
new webpack.BannerPlugin('This file is created by arthur'),
new webpack.LoaderOptionsPlugin({
options: {
postcss: function(){
return [
require("autoprefixer")({
browsers: ['ie>=8','>1% in CN']
})
]
}
}
})
],
module: {
loaders: [{
test: /\.jsx?$/,
exclude: [/node_modules/],
loaders: [
'react-hot-loader', 'babel-loader'
],
}, {
test: /\.(png|jpg|gif)$/,
loader: 'url-loader' // 这里的 limit=8192 表示用 base64 编码 <= 8K 的图像
}, {
test: /\.css$/,
loader: 'style-loader!css-loader'
}, {
test: /\.less$/,
loader: 'style-loader!css-loader!less-loader'
}],
rules: [
{
test: /\.jsx?$/,
exclude: [/node_modules/],
use: [
'babel-loader'
]
},
{
test: /\.(png|jpg|gif)$/,
use: [
'url-loader'
]
},
{
test: /\.css$/,
use: [
'style-loader','css-loader'
]
},
{
test: /\.less$/,
use: [
'style-loader','css-loader','less-loader',{
loader: 'postcss-loader',
options: {
plugins: function() {
return [
precss,autoprefixer
]
}
}
}
]
},
]
},
resolve: {
modules: [
path.join(__dirname, "app"),
"node_modules"
],
extensions: [".js", ".css", ".less", ".jsx", ".json"]
},
devServer: {
compress: true,
port: 9000,
// contentBase: './public'
},
devtool: 'inline',
}