-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
118 lines (110 loc) · 3.1 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
// Copyright (c) Wictor Wilén. All rights reserved.
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
var webpack = require('webpack');
const Dotenv = require('dotenv-webpack');
var TSLintPlugin = require('tslint-webpack-plugin');
var path = require('path');
var fs = require('fs');
var argv = require('yargs').argv;
var debug = argv.debug !== undefined;
const lint = argv["linting"];
var nodeModules = {};
fs.readdirSync('node_modules')
.filter(function (x) {
return ['.bin'].indexOf(x) === -1;
})
.forEach(function (mod) {
nodeModules[mod] = 'commonjs ' + mod;
});
var config = [{
entry: {
server: [
__dirname + '/src/app/server.ts'
],
},
mode: debug ? 'development' : 'production',
output: {
path: __dirname + '/dist',
filename: '[name].js',
devtoolModuleFilenameTemplate: debug ? '[absolute-resource-path]' : '[]'
},
externals: nodeModules,
devtool: 'source-map',
resolve: {
extensions: [".ts", ".tsx", ".js"],
alias: {}
},
target: 'node',
node: {
__dirname: false,
__filename: false,
},
module: {
rules: [{
test: /\.tsx?$/,
exclude: [/lib/, /dist/],
loader: "ts-loader"
}]
},
plugins: []
},
{
entry: {
client: [
__dirname + '/src/app/scripts/client.ts'
]
},
mode: debug ? 'development' : 'production',
output: {
path: __dirname + '/dist/web/scripts',
filename: '[name].js',
libraryTarget: 'umd',
library: 'swoopTeamsTab',
publicPath: '/scripts/'
},
externals: {},
devtool: 'source-map',
resolve: {
extensions: [".ts", ".tsx", ".js"],
alias: {}
},
target: 'web',
module: {
rules: [{
test: /\.tsx?$/,
exclude: [/lib/, /dist/],
loader: "ts-loader",
options: {
configFile: "tsconfig-client.json"
}
},
{
test: /\.(eot|svg|ttf|woff|woff2)$/,
loader: 'file-loader?name=public/fonts/[name].[ext]'
}
]
},
plugins: [
new Dotenv({
systemvars: true
})
],
performance: {
maxEntrypointSize: 400000,
maxAssetSize: 400000,
assetFilter: function(assetFilename) {
return assetFilename.endsWith('.js');
}
}
}
];
if (lint !== false) {
config[0].plugins.push(new TSLintPlugin({
files: ['./src/app/*.ts']
}));
config[1].plugins.push(new TSLintPlugin({
files: ['./src/app/scripts/**/*.ts', './src/app/scripts/**/*.tsx']
}));
}
module.exports = config;