forked from yumo-mt/justForYou
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
56 lines (56 loc) · 1.71 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
var path = require('path');
var webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin'); //css单独打包
var HtmlWebpackPlugin = require('html-webpack-plugin');
var openBrowserWebpackPlugin = require('open-browser-webpack-plugin');
module.exports = {
entry:path.resolve('src/app.js'),
output:{
path:'./build',
filename:'bundle.js',
chunkFilename:'js/[name].[chunkhash:5].js'
},
resolve:{
extensions:['','.js','.jsx','.css','.json'],
},
plugins:[
new HtmlWebpackPlugin({
title:'webpack',
template:'./src/index.html',
filename:'index.html'
}),
new openBrowserWebpackPlugin({url:'http://localhost:8800'})
],
devServer:{
port:8800,
contentBase:'./build',
inline:true,
stats: {
colors: true,
cached: false,
},
host: "0.0.0.0"
},
module:{
loaders:[
{
test: /\.js$/, //正则,匹配到的文件后缀名
loader: 'babel'
},
//加载css代码
{
test: /\.css/,
loader: 'style!css'
},
//配置信息的参数“?limit=8192”表示将所有小于8kb的图片都转为base64形式(其实应该说超过8kb的才使用url-loader 来映射到文件,否则转为data url形式)
{
test: /\.(woff|woff2|ttf|svg|eot)$/,
loader: "url?limit=10000"
},
{
test: /\.(png|jpg|jpeg|gif)$/,
loader: 'url?limit=10000&name=img/[name].[hash].[ext]'
},
]
}
}