forked from T-Macgrady/Tmacmall-admin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
98 lines (97 loc) · 2.88 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
96
97
98
/*
* @Author: Lizh
* @Date: 2018-05-20 23:06:56
* @Last Modified by: Lizh
* @Last Modified time: 2018-05-31 14:44:21
*/
const HtmlWebpackPlugin = require('html-webpack-plugin'); //installed via npm
const webpack = require('webpack'); //to access built-in plugins
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const path = require('path');
// 环境变量, dev, (test), online
var WEBPACK_ENV = process.env.WEBPACK_ENV || 'dev';
// webpack config
const config = {
entry: './src/app.jsx',
output: {
path: path.join(__dirname, 'dist'),
publicPath: WEBPACK_ENV === 'online' ? '//47.106.183.192:8080/admin-fe/dist/' : 'http://localhost:8086/dist/',
// publicPath : '/dist/',
filename: 'js/app.js'
},
externals: {
'jquery': 'window.jQuery'
},
module: {
rules: [{
test: /\.css$/,
loader: ExtractTextPlugin.extract({
use: 'css-loader',
fallback: 'style-loader'
})
}, {
test: /\.scss$/,
loader: ExtractTextPlugin.extract({
use: 'css-loader!sass-loader',
fallback: 'style-loader'
})
}, {
test: /\.(gif|jpg|png|woff|svg|eot|ttf)\??.*$/,
use: [{
loader: 'url-loader',
options: {
name: 'resource/[name].[ext]',
limit: 2000
}
}]
}, {
test: /\.jsx$/,
exclude: /(node_modules)/,
use: {
loader: 'babel-loader',
options: {
presets: ['env', 'react']
}
}
}]
},
resolve: {
alias: {
node_modules: path.join(__dirname, '/node_modules'),
util: path.join(__dirname, '/src/util'),
component: path.join(__dirname, '/src/component'),
service: path.join(__dirname, '/src/service'),
page: path.join(__dirname, '/src/page')
}
},
devServer: {
port: '8086', //设置端口号
// 路径的配置
historyApiFallback: {
index: '/dist/index.html'
},
proxy: {
'/manage': {
target: 'http://admintest.happymmall.com',
changeOrigin: true
},
'/user/logout.do': {
target: 'http://admintest.happymmall.com',
changeOrigin: true
}
}
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({
name: 'common',
filename: 'js/base.js'
}),
new HtmlWebpackPlugin({
template: './src/index.html',
filename: 'index.html',
favicon: './favicon.ico'
}),
new ExtractTextPlugin("css/[name].css"),
]
};
module.exports = config;