forked from ShuyunFF2E/ccms-components
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack-dev.config.js
97 lines (93 loc) · 2.42 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
/**
* @author Kuitos
* @homepage https://github.com/kuitos/
* @since 2015-08-06
*/
var path = require('path');
var webpack = require('webpack');
var autoprefixer = require('autoprefixer');
module.exports = {
devtool: 'source-map',
entry: {
components: ['webpack-hot-middleware/client?path=/__webpack_hmr&reload=true', './src/index.js'],
style: ['webpack-hot-middleware/client?path=/__webpack_hmr&reload=true', './src/components/styles/index.js']
},
output: {
path: path.join(__dirname, 'build'),
filename: '[name].js',
publicPath: '/' // hot loader publish dir
},
plugins: [
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin()
],
resolve: {
extensions: ['', '.js']
},
eslint: {
configFile: '.eslintrc',
emitWarning: true,
emitError: true,
formatter: require('eslint-friendly-formatter')
},
postcss: [autoprefixer({browsers: ['Chrome > 35', 'Firefox > 30', 'Safari > 7']})],
module: {
preLoaders: [
{
test: /\.js$/,
loader: 'eslint-loader',
exclude: /node_modules/,
include: [path.join(__dirname, 'src')]
}
],
loaders: [
{
test: /\.js?$/,
loaders: ['babel'],
exclude: /(node_modules|bower_components)/,
include: [path.join(__dirname, 'src')]
},
{
test: /\.html$/,
loader: 'html',
query: {interpolate: true},
exclude: /(node_modules|bower_components)/,
include: path.join(__dirname, 'src')
},
{
test: /\.css$/,
loaders: ['style', 'css?modules', 'postcss', 'resolve-url'],
exclude: /(node_modules|bower_components)/
},
{
test: /\.scss$/,
loaders: ['style', 'css', 'postcss', 'resolve-url', 'sass?sourceMap'],
exclude: /(node_modules|bower_components)/
},
{
test: /\.(jpe?g|png|gif|svg)$/i,
loaders: [
'file?hash=sha512&digest=hex&name=[hash:8].[ext]',
'image-webpack?bypassOnDebug&optimizationLevel=7&interlaced=false'
]
},
{
test: /\.(woff|woff2)(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url?limit=10000&mimetype=application/font-woff&prefix=fonts'
},
{
test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url?limit=10000&mimetype=application/octet-stream&prefix=fonts'
},
{
test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url?limit=10000&mimetype=application/vnd.ms-fontobject&prefix=fonts'
},
{
test: /\.svg(#\w+)?$/,
loader: 'url?limit=15000&mimetype=image/svg+xml&prefix=fonts'
}
]
}
};