/
webpack.config.js
32 lines (30 loc) · 1.19 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
var webpack = require('webpack');
var path = require('path');
var ExtractTextPlugin = require('extract-text-webpack-plugin'); //抽取CSS文件插件
var OpenBrowserPlugin = require('open-browser-webpack-plugin'); //自动打开浏览器插件
module.exports = {
entry: {
pages: __dirname +'/src/index.js',
vendors:['react','react-dom','react-router','reflux'] //第三方库和框架
},
output: {
publicPath: 'dist',
filename: 'js/bundle.js',
},
module: {
loaders: [
{ test: /\.css$/, loader: ExtractTextPlugin.extract('style', 'css') }, //坑:不能用叹号链接,必须写成这种格式
{ test: /\.less$/, loader: ExtractTextPlugin.extract('css!less') },
{ test: /\.js[x]?$/, exclude: /node_modules/, loader: 'babel' },
{ test: /\.(png|jpg)$/, loader: 'url?limit=8192&name=img/[name].[ext]' },
{ test: /\.(woff|woff2|eot|ttf|svg)(\?.*$|$)/, loader: 'url' }
]
},
resolve: {
extensions: ['', '.js', '.jsx'],
},
plugins: [
new webpack.optimize.CommonsChunkPlugin('vendors','js/vendors.js'),
new ExtractTextPlugin("css/bundle.css"),
]
};