forked from KyberNetwork/KyberSwap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.ieo.js
149 lines (142 loc) · 4.15 KB
/
webpack.config.ieo.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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
var webpack = require('webpack');
var path = require('path');
var ExtractTextPlugin = require('extract-text-webpack-plugin')
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
var CompressionPlugin = require('compression-webpack-plugin')
const WebpackShellPlugin = require('./webpack-shell-plugin');
// const HOST = process.env.HOST || "127.0.0.1";
// const PORT = process.env.PORT || "8889";
var scriptConfig = function (env) {
//var dist = env.chain ? '/dist/' + env.chain : '/src'
var dist = '../public/swap'
var chain = env.chain
return {
context: path.join(__dirname, "src"),
devtool: (env && env.build !== "true") ? "inline-sourcemap" : false,
entry: ['babel-polyfill', "./js/client.js", "./assets/css/app.scss"],
watchOptions: {
ignored: [ /node_modules/, /lang/ ]
},
module: {
loaders: [{
test: /\.jsx?$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel-loader',
query: {
presets: ['react', 'es2015', 'stage-0'],
plugins: ['react-html-attrs', 'transform-decorators-legacy', 'transform-class-properties'],
}
},
{
test: /\.css$/,
use: [ 'style-loader', 'css-loader' ],
},
{
test: /\.scss$/,
loader: ExtractTextPlugin.extract(['css-loader', 'sass-loader']),
},
{
test: /\.(jpe?g|png|gif|svg|ttf)$/i,
use: [
{
loader: 'url-loader',
options: {
limit: 2000000
}
}
]
}
]
},
output: {
// path: __dirname + dist,
// filename: "client.min.js"
publicPath: '/',
path: path.join(__dirname, '../public/swap/', chain),
filename: `client.min.js`
},
plugins: (env && env.build !== "true") ? [
new ExtractTextPlugin({ // define where to save the file
filename: 'app.bundle.css',
allChunks: true,
}),
new webpack.DefinePlugin({
'env': JSON.stringify(env.chain),
'process.env': {
'logger': 'true'
}
})
] : [
new UglifyJsPlugin({
uglifyOptions: {
comments: false,
compress: {
drop_console: true,
warnings: false
}
}
}),
new ExtractTextPlugin({ // define where to save the file
filename: 'app.bundle.css',
allChunks: true,
}),
new webpack.DefinePlugin({
'env': JSON.stringify(env.chain),
'process.env': {
'NODE_ENV': JSON.stringify("production")
}
}),
new CompressionPlugin({
asset: "[path].gz[query]",
algorithm: "gzip",
test: /\.js$|\.css$|\.html$/,
threshold: 10240,
minRatio: 0.8
}),
new WebpackShellPlugin(
{
// hash: hash,
// onBuildStart:['node webpack.beforebuild.js'],
onBuildEnd:[`BUNDLE_NAME=[hash] chain=${chain} node webpack.afterbuild.js`]
}
)
],
devServer: {
contentBase: "../public/swap/production",
// do not print bundle build stats
noInfo: true,
// enable HMR
hot: true,
// embed the webpack-dev-server runtime into the bundle
inline: true,
// serve index.html in place of 404 responses to allow HTML5 history
historyApiFallback: true,
// port: PORT,
// host: HOST
// compress: true,
// disableHostCheck: true,
// contentBase: "../public/swap/production"
}
}
};
var indexConfig = function (env) {
var HtmlWebpackPlugin = require('html-webpack-plugin')
var dist = env.chain ? '/dist/' + env.chain : '/src'
return {
entry: ['./src/client.min.js'],
output: {
path: __dirname + dist,
filename: 'client.min.js?v=' + Date.now()
},
plugins: [
new HtmlWebpackPlugin({
title: "Wallet - kyber.network",
template: './src/app.html',
favicon: './src/assets/img/favicon.png',
inject: 'body',
styleFile: 'app.bundle.css?v=' + Date.now()
})
]
}
}
module.exports = [scriptConfig, indexConfig]