Repository navigation
Expand file tree
/
Copy pathwebpack.dev.config.js
More file actions
97 lines (95 loc) · 2.57 KB
/
Copy pathwebpack.dev.config.js
File metadata and controls
97 lines (95 loc) · 2.57 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
//UglifyJsPlugin:会不会压缩已经压缩过的文件(react)
var path = require('path'),
webpack = require('webpack'),
CopyWebpackPlugin = require('copy-webpack-plugin'),
HtmlWebpackPlugin = require('html-webpack-plugin'),
CleanWebpackPlugin = require('clean-webpack-plugin'),
Dashboard = require('webpack-dashboard'),
DashboardPlugin = require('webpack-dashboard/plugin'),
dashboard = new Dashboard(),
HappyPack = require('happypack'),
ExtractTextPlugin = require('extract-text-webpack-plugin');
module.exports = {
entry: {
'index': './webpackVersion/scripts/home.js',
'react': ['react']
},
output: {
path: './dist',
filename: 'javascript/[name].js'
},
eslint: {
configFile: '.eslintrc',
emitWarnings: true
},
// 使用source-map,方便开发测试
devtool: 'source-map',
module: {
loaders: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
loader: 'babel',
query: {
presets: ['es2015', 'stage-0', 'react']
}
},
{
test: /\.(css|styl)/,
loader: ExtractTextPlugin.extract('style', '!css!stylus')
},
/* eslint-disable
{
test: /\.(eot|svg|ttf|woff(2)?)(\?v=\d+\.\d+\.\d+)?/,
loader: 'url'
}
/* eslint-disable */
]
},
plugins: [
new webpack.NoErrorsPlugin(),
new webpack.optimize.UglifyJsPlugin({
// js压缩: 已经压缩过的文件是否还会被压缩?
compress: {
warnings: false
}
}),
new HappyPack({
// loaders is the only required parameter:
loaders: ['babel-loader'],
threads: 2
}),
new webpack.optimize.CommonsChunkPlugin({
// 提取公共模块
name: ['react'],
minChunks: Infinity // 提取所有entry共同依赖的模块
}),
new CleanWebpackPlugin(['dist'], {
// 清空dist目录
dry: false, // do not delete anything, good for testing.
verbose: true,
root: __dirname// webpack.config file path.
}),
new webpack.ProvidePlugin({
'notes.css': './static/style/common/notes.styl'
}),
new ExtractTextPlugin('css/[name].css'),
new HtmlWebpackPlugin({
path: path.resolve(__dirname, './dist'),
className: 'wrapper',
date: '2016/04/01',
title: 'ZJDGX',
filename: path.resolve(__dirname, './index.html'),
template: __dirname + '/webpackVersion/template.ejs',
inject: true
}),
new CopyWebpackPlugin([
// 复制images目录
//{from: './static/images', to: 'image'},
{from: './static/javascript/lib/frame.js', to: 'javascript'},
//{from: './static/notes', to: 'notes'},
//{from: './static/style/notes.css', to: 'css/notes.css'}
]),
new DashboardPlugin(dashboard.setData)
]
}