/
webpack.config.js
72 lines (68 loc) · 1.96 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
69
70
71
72
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextWebpackPlugin = require('extract-text-webpack-plugin');
var OpenBrowserPlugin = require('open-browser-webpack-plugin')
module.exports = {
entry: {
index: [
'./app/index.jsx'
]
},
output: {
path: './dist',
filename: '[name].js'
},
resolve: {
extensions: ['', '.js', '.jsx']
},
module: {
loaders: [
//单独css
{ test: /\.css$/, loader: "style-loader!css-loader!postcss-loader" },
{ test: /\.less$/, loader: 'style!css!postcss!less' },
{ test: /\.scss$/, loader: 'style!css!postcss!sass' },
{
test: /\.(js|jsx)$/,
loader: 'babel-loader',
exclude: '/node_modules/',
query: {
presets: ['react', 'es2015']
}
},
//提供html内嵌的imgurl支持
{ test: /\.html$/, loader: 'html-withimg-loader' },
{ test: /\.(png|gif|jpg|woff|svg|eot|ttf)\??.*$/, loader: 'url-loader?limit=8192&name=/resource/[name].[ext]' },
]
},
externals: {
'react': 'React',
'react-dom': 'ReactDOM'
},
plugins: [
//提取公共模块
new webpack.optimize.CommonsChunkPlugin({
name: 'commons',
filename: 'js/base.js'
}),
//单独打包css
new ExtractTextWebpackPlugin(
'./css/[name].css'
),
//html模板插件
new HtmlWebpackPlugin({
template: './app/index.tmpl.html',
filename: 'index.html',
inject: true,
hash: true,
chunks: ['commons', 'index']
}),
],
devServer: {
proxy: {
'/api': {
target: 'http://localhost:8080',
secure: false
}
}
}
}