-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.ts
70 lines (65 loc) · 1.66 KB
/
webpack.config.ts
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
import path from 'path';
import webpack from 'webpack';
import CopyWebpackPlugin from 'copy-webpack-plugin';
import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin';
import { webpackPort } from 'src/server/config';
const ROOT = path.resolve(__dirname);
const DIST = path.resolve('./dist');
const CLIENT = path.resolve('./src/client');
const config = {
mode: 'development',
devtool: 'source-map',
context: ROOT,
entry: ['./src/client/index.tsx'],
output: {
path: DIST,
filename: 'client.js',
publicPath: '/'
},
module: {
rules: [{
test: /\.tsx?$/,
include: CLIENT,
loader: 'ts-loader',
options: {
configFile: path.resolve('./config/tsconfig.client.json'),
transpileOnly: true
}
}]
},
resolve: {
alias: {
src: path.resolve('./src')
},
extensions: ['.js', '.ts', '.tsx']
},
plugins: [
new webpack.DefinePlugin({
__DEV__: !['production', 'test'].includes(process.env.NODE_ENV)
}),
new CopyWebpackPlugin([
{ from: 'src/client/index.html' }
])
]
};
if (process.env.NODE_ENV === 'production') {
config.plugins.push(
new webpack.optimize.UglifyJsPlugin({
compress: { warnings: false }
})
);
} else if (process.env.NODE_ENV !== 'test') {
config.entry.unshift(
`webpack-dev-server/client?http://localhost:${webpackPort}/`,
'webpack/hot/dev-server'
);
config.plugins.push(
new webpack.HotModuleReplacementPlugin(),
new webpack.NamedModulesPlugin(),
new ForkTsCheckerWebpackPlugin({
tsconfig: './config/tsconfig.client.json',
tslint: './config/tslint.json'
})
);
}
export default config;