1 | const paths = require('./paths')
|
2 | const nodeExternals = require('webpack-node-externals')
|
3 | const tsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin')
|
4 | const forkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin')
|
5 |
|
6 | const formatForkTsCheckerMessages = require('./formatForkTsCheckerMessages')
|
7 | const formatTsLoaderMessages = require('./formatTsLoaderMessages')
|
8 | const { tslintShouldEmitErrors } = require('./tsLintHelper')
|
9 |
|
10 | module.exports = {
|
11 | mode: 'development',
|
12 | entry: paths.appIndexJs,
|
13 | target: 'node',
|
14 | externals: [nodeExternals()],
|
15 | devtool: 'inline-source-map',
|
16 | output: {
|
17 | path: paths.appDevBundlePath,
|
18 | filename: 'bundle.js',
|
19 | libraryTarget: 'commonjs',
|
20 | },
|
21 | resolve: {
|
22 | extensions: ['.ts', '.tsx', '.js', 'jsx', '.json'],
|
23 | plugins: [
|
24 | new tsconfigPathsPlugin({
|
25 | configFile: paths.appTsConfig,
|
26 | }),
|
27 | ],
|
28 | },
|
29 | module: {
|
30 | rules: [
|
31 | {
|
32 | test: /\.tsx?$/,
|
33 | enforce: 'pre',
|
34 | use: [
|
35 | {
|
36 | loader: require.resolve('tslint-loader'),
|
37 | options: {
|
38 | emitErrors: tslintShouldEmitErrors(paths.appTsLint),
|
39 | tsConfigFile: paths.appTsConfig,
|
40 | configFile: paths.appTsLint,
|
41 | formatter: 'lintTable',
|
42 | formattersDirectory: __dirname + '/formatters/',
|
43 | },
|
44 | },
|
45 | ],
|
46 | },
|
47 | {
|
48 | test: /\.jsx?$/,
|
49 | include: paths.appSrc,
|
50 | exclude: /node_modules/,
|
51 | loader: require.resolve('babel-loader'),
|
52 | options: {
|
53 | babelrc: false,
|
54 | presets: [require.resolve('@babel/preset-env')],
|
55 | compact: true,
|
56 | },
|
57 | },
|
58 | {
|
59 | test: /\.tsx?$/,
|
60 | include: paths.appSrc,
|
61 | loader: require.resolve('ts-loader'),
|
62 | options: {
|
63 | transpileOnly: true,
|
64 | experimentalWatchApi: true,
|
65 | errorFormatter: formatTsLoaderMessages({}),
|
66 | },
|
67 | },
|
68 | ],
|
69 | },
|
70 | plugins: [
|
71 | new forkTsCheckerWebpackPlugin({
|
72 | silent: true,
|
73 | async: false,
|
74 | watch: paths.appSrc,
|
75 | tsconfig: paths.appTsConfig,
|
76 | formatter: formatForkTsCheckerMessages({}),
|
77 | }),
|
78 | ],
|
79 | optimization: {
|
80 | nodeEnv: false,
|
81 | },
|
82 | node: {
|
83 | __dirname: false,
|
84 | __filename: false,
|
85 | },
|
86 | performance: {
|
87 | hints: false,
|
88 | },
|
89 | }
|