remaxjs / remax
1 1
import * as path from 'path';
2 1
import { DefinePlugin } from 'webpack';
3
import Config from 'webpack-chain';
4 1
import { CleanWebpackPlugin } from 'clean-webpack-plugin';
5 1
import alias from '../utils/alias';
6 1
import getEnvironment from '../utils/env';
7 1
import * as webpack from 'webpack';
8
import Builder from '../Builder';
9

10 1
export default function baseConfig(config: Config, builder: Builder) {
11 1
  config.resolveLoader.modules
12
    .merge(['node_modules', path.join(__dirname, './loaders')])
13
    .end()
14
    .extensions.merge(['.js', '.ts']);
15

16 1
  config.mode((process.env.NODE_ENV as any) === 'production' ? 'production' : 'development');
17

18 1
  config.context(builder.options.cwd);
19

20 1
  config.resolve.alias.merge(alias(builder.options, builder.target));
21

22 1
  config.output.path(path.join(builder.options.cwd, builder.options.output));
23

24 1
  const env = getEnvironment(builder.options, builder.target);
25 1
  config.plugin('webpack-define-plugin').use(DefinePlugin, [env.stringified]);
26 1
  config.plugin('provide-regeneratorRuntime').use(webpack.ProvidePlugin, [
27
    {
28
      regeneratorRuntime: 'regenerator-runtime',
29
    },
30
  ]);
31

32 1
  if (process.env.NODE_ENV === 'production') {
33 0
    config.plugin('clean-webpack-plugin').use(CleanWebpackPlugin);
34
  }
35

36 1
  config.devServer
37
    .publicPath(config.get('publicPath'))
38
    .compress(true)
39
    .hot(true)
40
    .open(false)
41
    .historyApiFallback(true)
42
    .noInfo(true);
43

44 1
  return config;
45
}

Read our documentation on viewing source code .

Loading