-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathwebpack.config.js
68 lines (66 loc) · 2.24 KB
/
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
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
var webpack = require("webpack");
var path = require('path');
var gutil = require("gulp-util");
var node_modules = path.resolve(__dirname, 'node_modules');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var precss = require('precss');
var autoprefixer = require('autoprefixer');
var myConfig = {
debug: true,
devtool: 'source-map',
entry: ['webpack-hot-middleware/client?reload=true',path.resolve(__dirname, 'app/main.js')],
context: path.resolve(process.cwd(), 'app'),
output: {
path: path.resolve(__dirname, 'build'),
filename: 'main.js',
publicPath: ""
},
module: {
loaders: [{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel',
query: {
"presets": ["react", "es2015", "stage-0", "react-hmre"]
}
}, {
test: /\.jade$/,
loader: 'html!jade-html'
}, {
test: /\.css$/,
loader: 'style!css'
}, {
test: /\.sass$/,
loader: "style!css!postcss-loader!sass?indentedSyntax&includePaths[]=" + path.resolve(__dirname, "./node_modules/compass-mixins/lib") + "&includePaths[]=" + path.resolve(__dirname, "./mixins/app_mixins")
}, {
test: /\.(png|jpg)$/,
loader: 'url-loader?limit=10000&name=[path][name]-[hash:8].[ext]'
}]
},
postcss: function () {
return [precss, autoprefixer];
},
resolve: {
root: [path.resolve(process.cwd(), 'app'), path.resolve(__dirname, 'node_modules')], //设置搜索目录
alias: {
images: './images'
},
extensions: ['', '.js', '.jade', '.jsx']
},
plugins: [
new HtmlWebpackPlugin({ // Also generate a test.html
filename: 'index.html',
template: 'index.html',
}),
new webpack.NoErrorsPlugin(),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.HotModuleReplacementPlugin(),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('development')
}),
new webpack.ProgressPlugin(function handler(percentage, msg) {
gutil.log(msg)
})
]
};
module.exports = myConfig;