-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathwebpack.config.js
62 lines (61 loc) · 1.66 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
const path = require('path');
const ROOT_PATH = path.resolve(__dirname);
const APP_PATH = path.resolve(ROOT_PATH, 'components');
const webpack = require('webpack');
const UglifyJsPlugin = require('uglify-js-plugin');
module.exports = {
devtool: "eval-source-map",
entry: __dirname + '/src/index.jsx',
//webpack的入口文件只有一个,所以写的所有components甚至包括css/json什么的,都要引用在这里
output:{
path: __dirname +'/public',
filename: 'bundle.js',
},
//我这边是新建了一个folder叫public,用来放index.html和bundle.js
devServer: {
contentBase: "./public",//本地服务器所加载的页面所在的目录
historyApiFallback: true,//不跳转
inline: true//实时刷新
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.optimize.UglifyJsPlugin({minimize: true}),
],
module: {
loaders: [
{
test: /\.jsx$/,
loader:'babel-loader',
exclude: /node_modules/
}, {
test: /\.js$/,
loader:'babel-loader',
exclude: /node_modules/
},{
test: /\.scss$/,
loaders: ['style-loader', 'css-loader?modules','sass-loader'],
exclude: /node_modules/
},{
test: /\.css$/,
loaders: ['style-loader', 'css-loader?modules'],
},{
test: /\.(png|jpg|jpeg)$/,
loader: 'file-loader'
},{
test: /\.json$/,
loader: 'json-loader',
exclude: /node_modules/
}]
},
resolve:{
extensions: ['.js', '.jsx']
},
externals: {
"jquery":"jQuery",
"react":"React",
"redux":"Redux",
"react-dom" :"ReactDOM",
"react-redux":"ReactRedux"
"thunk":"ReduxThunk"
},
};