-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
executable file
·95 lines (94 loc) · 3.21 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/**
* @file 文件打包编译配置文件
* @author [email protected]
* */
var webpack = require('webpack');
var path = require('path');
var nodeModulesPath = './node_modules';
module.exports = {
entry: {
// lib: './index.js',
// demo: './examples/demo.js',
doc: './docs/doc.js'
// lib: './index.js'
// demo: './examples/demo.js'
// react: ['react'],
// jquery: ['jquery']
// app: './indey.js',
// demoWj: './examples/demo_wj.js',
// demoRxt: './examples/demo_rxt.js'
// picCroper: './examples/picCroper.js'
},
output: {
path: 'dist/js',
publicPath: '../../',
filename: '[name].bundle.js'
},
module: {
noParse: [
path.join(nodeModulesPath, '/react/dist/react.min'),
path.join(nodeModulesPath, '/react-dom/dist/react-dom.min'),
path.join(nodeModulesPath, 'antd/dist/antd.min'),
path.join(nodeModulesPath, 'react-bootstrap/dist/react-bootstrap.min'),
path.join(nodeModulesPath, 'immutable/dist/immutable.min')],
loaders: [
{
test: /\.scss$/,
loaders: 'style-loader!css-loader!sass-loader'
}, {
test: /\.(js|jsx)$/,
exclude: /node_modules/,
loader: 'babel-loader',
query: {
presets: ['react', 'es2015', 'stage-0'],
compact: false
}
}, {
test: /\.css$/,
loader: 'style-loader!css-loader'
}, {
test: /\.(png|jpg)$/,
loader: 'url-loader?limit=8192'
}, {
test: /\.json$/,
loader: 'json-loader'
}, {
test: /\.woff|\.woff2|\.svg|.eot|\.ttf/,
loader: 'url?prefix=font/&limit=10000'
}
]
},
sassLoader: {
// includePaths: [path.resolve(__dirname, nodeModulesPath.'/sass-loader')]
},
resolve: {
// require('file') replace require('file.js')
extensions: ['', '.js', '.jsx', '.json'],
alias: {
// 打包到一起,直接指向react文件,提高webpack的搜索速度,部署上线的时候指向react.min.js
// 'react': path.join(nodeModulesPath, '/react/dist/react.min'),
// 'react-dom': path.join(nodeModulesPath, '/react-dom/dist/react-dom')
// 'immutable': path.join(nodeModulesPath, 'immutable/dist/immutable'),
// 'react-bootstrap': path.join(nodeModulesPath, '/react-bootstrap/dist/react-bootstrap'),
}
},
plugins: [
/*new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
}),//引入全局jquery
new CommonsChunkPlugin({
name: ['jquery', 'react'], // 公共模块提取
minChunks: Infinity
})
new webpack.optimize.UglifyJsPlugin({
compress: {
// warning: false
}
})*/
]
// import react导致文件变大,编译速度慢的解决方案
/*externals: { //不打包到一起,在<script>中引入
react: React
},*/
};