forked from honest-cash/honestcash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
93 lines (88 loc) · 2.71 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
const webpack = require("webpack");
require('dotenv').config();
const API_URLS = {
prod: "https://honest.cash/api",
dev: "https://beta.honest.cash/api",
local: "http://localhost:8080/api"
};
module.exports = (env, argv) => {
console.log(`BUILDING MODE: "${argv.env}"`);
return {
entry: {
app: "./src/app/app.ts",
},
mode: process.env.MODE || "production",
output: {
path: __dirname + "/public/js",
filename: "[name].js",
},
devtool: process.env.MODE === "development" ? "source-map" : "",
module: {
rules: [
{
test: /\.(js|ts)?$/,
loader: "ts-loader",
exclude: [ __dirname + "/node_modules/" ],
options: {
transpileOnly: true // IMPORTANT! use transpileOnly mode to speed-up compilation
}
}, {
test: /\.(css|less)?$/,
use: [{
loader: 'style-loader' // creates style nodes from JS strings
}, {
loader: 'css-loader' // translates CSS into CommonJS
}, {
loader: 'less-loader' // compiles Less to CSS
}]
}, {
test: /\.html$/,
use: [ "html-loader" ],
}, {
test: /\.ts$/,
enforce: 'pre',
use: [
{
loader: 'tslint-loader',
options: { /* Loader options go here */ }
}
]
}
]
},
plugins: [
new webpack.DefinePlugin({
__ENV__: JSON.stringify(argv.env),
__API_URL__: JSON.stringify(API_URLS[argv.env])
})
/**
new Uglify({
uglifyOptions: {
cache: true,
ecma: 7,
compress: {
warnings: false,
// Disabled because of an issue with Uglify breaking seemingly valid code:
// https://github.com/facebookincubator/create-react-app/issues/2376
// Pending further investigation:
// https://github.com/mishoo/UglifyJS2/issues/2011
comparisons: false,
},
mangle: {
keep_fnames: true,
reserved: ["BigInteger","ECPair","Point"],
},
output: {
//comments: false,
// Turned on because emoji and regex is not minified properly using default
// https://github.com/facebookincubator/create-react-app/issues/2488
//ascii_only: true,
},
},
}),
*/
],
resolve: {
extensions: [ ".tsx", ".ts", ".js" ]
}
}};