forked from KyberNetwork/KyberSwap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
97 lines (90 loc) · 2.91 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
const path = require('path');
const webpack = require('webpack');
//const ExtractTextPlugin = require('extract-text-webpack-plugin');
const CleanPlugin = require('clean-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const CompressionPlugin = require('compression-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin')
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
module.exports = env => {
const outputPath = env.chain ? 'dist/' + env.chain : '/src';
const timestamp = Date.now();
let entry = {
app: ['babel-polyfill', path.resolve(__dirname, 'src/js/client.js'), path.resolve(__dirname, 'src/assets/css/app.scss')]
};
let plugins = [
new webpack.ProgressPlugin(),
new MiniCssExtractPlugin({
filename: "[name].css",
}),
new CleanPlugin([outputPath + '/app.*', outputPath + '/libary.*']),
new HtmlWebpackPlugin({
title: 'Wallet - kyber.network',
template: './app.html',
favicon: './assets/img/favicon.png',
inject: 'body'
}),
new webpack.DefinePlugin({
'env': JSON.stringify(env.chain),
'process.env': {
'logger': 'true',
'env': JSON.stringify(env.chain)
}
})
];
return {
context: path.join(__dirname, 'src'),
mode: env && env.build === 'true' ? "production" : "development",
devtool: env && env.build === 'true' ? false : 'inline-sourcemap',
entry: entry,
output: {
path: path.join(__dirname, outputPath),
filename: `[name].min.${timestamp}.js`,
publicPath: '/'
},
module: {
rules: [{
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|sass|scss)$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
importLoaders: 2,
sourceMap: true
}
},
{
loader: 'sass-loader',
options: {
sourceMap: true
}
}
]
},
{
test: /\.(jpe?g|png|gif|svg|ttf)$/i,
use: [
{
loader: 'url-loader',
options: {
limit: 10000
}
}
]
}
]
},
plugins: plugins
}
};