-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.dev.js
69 lines (67 loc) · 2.16 KB
/
webpack.config.dev.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 path = require('path');
var webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: {
index: './src/js/index',
list: './src/js/list',
common: ['./src/js/lib/jquery.js', './src/js/lib/jquery.colorbox.js']
},
output: {
path: path.join(__dirname, 'dist'),
filename: 'js/[name].bundle.js',
publicPath: '/'
},
resolve: {
alias: {
'jquery': path.resolve(__dirname, 'src/js/lib/jquery'),
'c': path.resolve(__dirname, 'src/js/modules/controller'),
'm': path.resolve(__dirname, 'src/js/modules'),
'scss': path.resolve(__dirname, 'src/scss')
}
},
externals: {
'jquery': 'jQuery'
},
devtool: 'source-map',
module: {
loaders: [{
test: /\.css$/,
loader: ExtractTextPlugin.extract('style', 'css')
},
{
test: /\.scss$/,
// loader: 'style!css!sass'
loader: ExtractTextPlugin.extract('style', 'css?sourceMap!sass?sourceMap')
},
{
/**
* loader ? 后边的 query 有两种写法, 可以看下文档:
* http://webpack.github.io/docs/using-loaders.html#query-parameters
*/
test: /\.(jpe?g|png|gif|svg)$/i,
// loader: 'url?limit=8192&name=images/[name].[ext]?[hash]'
loaders: [
'url?limit=81&name=/images/[name].[ext]?[hash]',
'image-webpack?optimizationLevel=3'
]
}]
},
plugins: [
new webpack.optimize.CommonsChunkPlugin('common', 'js/common.js'),
new ExtractTextPlugin('css/[name].css'),
new HtmlWebpackPlugin({
template: './pages/list.html',
filename: 'list.html',
inject: 'body',
chunks: ['common', 'list']
}),
new HtmlWebpackPlugin({
template: './pages/index.html',
filename: 'index.html',
inject: 'body',
chunks: ['common', 'index']
})
]
};