1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.createWebpackConfig = void 0;
|
4 | const tslib_1 = require("tslib");
|
5 | const case_sensitive_paths_webpack_plugin_1 = (0, tslib_1.__importDefault)(require("case-sensitive-paths-webpack-plugin"));
|
6 | const fork_ts_checker_webpack_plugin_1 = (0, tslib_1.__importDefault)(require("fork-ts-checker-webpack-plugin"));
|
7 | const tsconfig_paths_webpack_plugin_1 = (0, tslib_1.__importDefault)(require("tsconfig-paths-webpack-plugin"));
|
8 | const webpack_node_externals_1 = (0, tslib_1.__importDefault)(require("webpack-node-externals"));
|
9 | const clean_webpack_plugin_1 = require("clean-webpack-plugin");
|
10 | const eslint_webpack_plugin_1 = (0, tslib_1.__importDefault)(require("eslint-webpack-plugin"));
|
11 | const formatTsLoaderMessages_1 = require("./formatTsLoaderMessages");
|
12 | const paths_1 = require("./paths");
|
13 | const env_1 = require("../util/env");
|
14 | const createWebpackConfig = (environment) => {
|
15 | const isDev = environment === 'development';
|
16 | return {
|
17 | mode: environment,
|
18 | entry: paths_1.paths.appIndexJs,
|
19 | target: 'node',
|
20 | externals: [
|
21 | (0, webpack_node_externals_1.default)(env_1.RuntimeOptions.useMonorepo
|
22 | ? {
|
23 | modulesFromFile: true,
|
24 | }
|
25 | : undefined),
|
26 | ],
|
27 | devtool: isDev ? 'eval-cheap-module-source-map' : 'source-map',
|
28 | output: {
|
29 | path: isDev ? paths_1.paths.appDevBundlePath : paths_1.paths.appBuild,
|
30 | filename: isDev ? 'bundle.js' : 'bundle.prod.js',
|
31 | libraryTarget: 'commonjs',
|
32 | },
|
33 | resolve: {
|
34 | extensions: ['.ts', '.js', '.json'],
|
35 | plugins: [
|
36 | new tsconfig_paths_webpack_plugin_1.default({
|
37 | configFile: paths_1.paths.appTsConfig,
|
38 | silent: true,
|
39 | }),
|
40 | ],
|
41 | },
|
42 | module: {
|
43 | rules: [
|
44 | {
|
45 | test: /\.jsx?$/,
|
46 | include: paths_1.paths.appSrc,
|
47 | exclude: /node_modules/,
|
48 | loader: require.resolve('babel-loader'),
|
49 | options: {
|
50 | babelrc: false,
|
51 | presets: [require.resolve('@babel/preset-env')],
|
52 | compact: true,
|
53 | },
|
54 | },
|
55 | {
|
56 | test: /\.tsx?$/,
|
57 | include: paths_1.paths.appSrc,
|
58 | loader: require.resolve('ts-loader'),
|
59 | options: {
|
60 | transpileOnly: true,
|
61 | errorFormatter: formatTsLoaderMessages_1.formatTsLoaderMessages,
|
62 | },
|
63 | },
|
64 | ],
|
65 | },
|
66 | plugins: [
|
67 | new eslint_webpack_plugin_1.default({
|
68 | eslintPath: require.resolve('eslint'),
|
69 | extensions: ['js', 'ts', 'jsx', 'tsx'],
|
70 | formatter: 'stylish',
|
71 | emitWarning: true,
|
72 | resolvePluginsRelativeTo: __dirname,
|
73 | overrideConfigFile: paths_1.paths.appEslint,
|
74 | }),
|
75 | new fork_ts_checker_webpack_plugin_1.default({
|
76 | async: false,
|
77 | typescript: {
|
78 | configFile: paths_1.paths.appTsConfig,
|
79 | },
|
80 | formatter: 'codeframe',
|
81 | }),
|
82 | new case_sensitive_paths_webpack_plugin_1.default(),
|
83 | new clean_webpack_plugin_1.CleanWebpackPlugin(),
|
84 | ],
|
85 | optimization: {
|
86 | nodeEnv: false,
|
87 | },
|
88 | node: {
|
89 | __dirname: false,
|
90 | __filename: false,
|
91 | },
|
92 | performance: {
|
93 | hints: false,
|
94 | },
|
95 | };
|
96 | };
|
97 | exports.createWebpackConfig = createWebpackConfig;
|
98 |
|
\ | No newline at end of file |