forked from online-go/online-go.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
100 lines (83 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
94
95
96
97
98
99
100
'use strict';
console.log('node path :', process.env.NODE_PATH)
var path = require('path');
let fs = require('fs');
var webpack = require('webpack');
const pkg = require('./package.json');
const production = process.env.PRODUCTION ? true : false;
let plugins = [];
plugins.push(new webpack.BannerPlugin(
`Copyright (C) 2012-2017 Online-Go.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
`));
plugins.push(
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks: function (module) {
return module.context && module.context.indexOf('node_modules') !== -1;
}
})
);
if (production) {
plugins.push(
new webpack.DefinePlugin({
"process.env": {
NODE_ENV: JSON.stringify("production")
}
})
);
}
module.exports = {
entry: {
'ogs': './src/main.tsx',
},
resolve: {
modules: [
'src/lib',
'src/lib/goban',
'src/components',
'src/views',
'src/data',
'src/compatibility',
'src',
'node_modules'
],
extensions: [".webpack.js", ".web.js", ".ts", ".tsx", ".js"],
},
output: {
path: __dirname + '/dist',
filename: production ? '[name].min.js' : '[name].js'
},
module: {
loaders: [
// All files with a '.ts' or '.tsx' extension will be handled by 'ts-loader'.
{
test: /\.tsx?$/,
loader: "ts-loader",
exclude: /node_modules/,
}
]
},
performance: {
maxAssetSize: 1024 * 1024 * 2.5,
maxEntrypointSize: 1024 * 1024 * 2.5,
},
plugins: plugins,
devtool: 'source-map',
// When importing a module whose path matches one of the following, just
// assume a corresponding global variable exists and use that instead.
// This is important because it allows us to avoid bundling all of our
// dependencies, which allows browsers to cache those libraries between builds.
externals: {
"swal": "swal", // can't seem to import anyways
},
};