-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
127 lines (120 loc) · 4.01 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
var path = require('path');
var base = require("./base");
var webpack = require('webpack');
var autoprefixer = require('autoprefixer');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var mode = base.mode
var isProd = base.isProd;
var publicPath = base.publicPath
var isDevProd = mode === 'devprod'
// var kkwap = base.kkwap
var dist = path.join(__dirname, base.root, base.projectName);
var projectSrc = path.join(__dirname, base.root, base.projectName,'src/');
var extractCSS = new ExtractTextPlugin('css/[name].css?[hash:8]');
var extractSASS = new ExtractTextPlugin('css/[name].css?[hash:8]');
var plugins = [];
var entryObj = {};
if(isProd){
plugins.push(
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
})
);
}
plugins.push(extractCSS);
plugins.push(extractSASS);
base.pageConfig.map(function(item,i) {
base.pageConfig[i].template = projectSrc+base.pageConfig[i].template;
base.pageConfig[i].chunks.map(function(_item,_i){
if(entryObj[_item] != base.sourceList.jsList[_item]){
entryObj[_item] = base.sourceList.jsList[_item]
}
})
plugins.push(new HtmlWebpackPlugin(base.pageConfig[i]));
});
module.exports = {
entry: entryObj,
output: {
path: dist,
filename: "js/[name].js",
chunkFilename: "js/[chunkhash].js",
//publicPath: isProd ? (publicPath ?( !kkwap ? '/acts/projects/'+base.projectName+'/' : '/kkwap/acts/projects/'+base.projectName+'/' ): "./") : "/",
//publicPath: (isProd || isDevProd) ? (publicPath === 'true' ? ('/acts/projects/'+base.projectName+'/') : ( (publicPath !== '' && publicPath) ? '/'+publicPath+'/acts/projects/'+base.projectName+'/' : '/acts/projects/'+base.projectName+'/' ) ) : '/'
publicPath: (isProd || isDevProd) ? (publicPath === 'true' ? ('/acts/projects/'+base.projectName+'/') : ( (publicPath !== '' && publicPath) ? publicPath+'/' : '/acts/projects/'+base.projectName+'/' ) ) : '/'
},
resolve: {
extensions: ['', '.coffee', '.js','.es6','.css','.scss','.png','.jpg','.jpeg','.gif']
},
module: {
loaders: [
{
test: /\.css$/,
loader: extractCSS.extract(['css','postcss'])
},
{
test: /\.ejs$/,
loader: 'ejs-compiled?src='+path.join(projectSrc,'views/')
},
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
query: {
presets: ['es2015', 'stage-2'],
cacheDirectory:'',
plugins: ["transform-runtime"]
}
},
{
test: /\.scss$/,
loader: extractSASS.extract(['css','postcss','sass']),
exclude: /node_modules/
},
{
test: /\.(png|gif|jpe?g|svg|eot|ttf|woff|woff2)$/,
loader: 'url?limit=8192&name=images/[name].[ext]?[hash:8]!image-webpack?{ progressive:true, optimizationLevel: 7 }',
exclude: /node_modules/
}
]
},
'ejs-compiled-loader': {
'htmlmin': false,
'htmlminOptions': {
removeComments: false
}
},
postcss:[autoprefixer()],
plugins:plugins,
devServer: {
contentBase:dist,
outputPath: dist,
colors: true,
historyApiFallback: true,
hot: true,
inline: true,
progress: true,
port:8088,
autoOpenBrowser: true,
proxy: {
'/kkapi': {
target: 'http://192.168.1.240/',
pathRewrite: {'^/kkapi' : '/kkapi'},
changeOrigin: true
},
'/Kkzc': {
target: 'http://192.168.1.240/',
pathRewrite: {'^/Kkzc' : '/Kkzc'},
changeOrigin: true
},
'/resources': {
target: 'http://192.168.1.240/',
pathRewrite: {'^/resources' : '/resources'},
changeOrigin: true
}
}
},
devtool: (isProd && !isDevProd) ? '' : 'source-map'
}