forked from stevenans9859/CoinSpace
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.prod.js
118 lines (112 loc) · 3.37 KB
/
webpack.prod.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
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const ProgressBarPlugin = require('progress-bar-webpack-plugin');
const autoprefixer = require('autoprefixer');
const Dotenv = require('dotenv-webpack');
const merge = require('webpack-merge');
const common = require('./webpack.common.js');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const path = require('path');
const envFile = process.env.ENV_FILE ? process.env.ENV_FILE : '.env.prod';
var config = merge(common, {
output: {
publicPath: '/'
},
devtool: 'hidden-source-map',
module: {
rules: [
{
test: /\.js$/,
exclude: [
path.resolve(__dirname, './phonegap/deviceready'),
path.resolve(__dirname, './app/loader'),
path.resolve(__dirname, './app/lib/i18n'),
/node_modules\/lodash/,
/node_modules\/ethjs-util/,
/node_modules\/eosjs/,
/node_modules\/js-xdr/,
/node_modules\/clipboard/,
/node_modules\/@sentry/
],
use: {
loader: 'babel-loader',
options: {
presets: [[
'env', {
useBuiltIns: 'entry'
}
]],
}
}
},
{
test: /\.(sass|scss)$/,
use: ExtractTextPlugin.extract({
use: [
{
loader: 'css-loader',
options: {
minimize: true
}
},
{
loader: 'postcss-loader',
options: {
plugins: [
autoprefixer
]
}
},
{
loader: 'sass-loader'
}
],
fallback: 'style-loader',
publicPath: '../../'
})
},
]
},
plugins: [
new CleanWebpackPlugin(['./build'], {verbose: false}),
new ProgressBarPlugin(),
new Dotenv({
path: envFile,
safe: true
}),
new UglifyJSPlugin({
sourceMap: true,
uglifyOptions: {
mangle: {
reserved: ['BigInteger','ECPair','Point', '_', 'RippleError', 'RippledError', 'UnexpectedError',
'LedgerVersionError', 'ConnectionError', 'NotConnectedError',
'DisconnectedError', 'TimeoutError', 'ResponseFormatError',
'ValidationError', 'NotFoundError', 'MissingLedgerHistoryError',
'PendingLedgerVersionError'
]
}
}
}),
new ExtractTextPlugin({
filename: 'assets/css/all.[contenthash:8].css',
allChunks: true,
}),
new CopyWebpackPlugin([
{from: `app/apple-developer-merchantid-domain-association.${process.env.ENV}.txt`, to: '.well-known/apple-developer-merchantid-domain-association.txt'},
])
]
});
if (process.env.BUILD_TYPE === 'phonegap') {
var htmlPlugin = config.plugins.find(function(plugin) {
return plugin instanceof HtmlWebpackPlugin;
});
htmlPlugin.options.chunks = ['deviceready'];
config.entry['deviceready'] = './phonegap/deviceready.js';
delete config.entry['loader'];
config.output.publicPath = '';
} else if (process.env.BUILD_TYPE === 'electron') {
config.output.publicPath = './';
}
module.exports = config;