1 const MiniCssExtractPlugin = require('mini-css-extract-plugin');
2 const nodeExternals = require('webpack-node-externals');
3 const path = require('path');
5 module.exports = function (env, _) {
9 entry: './src/server/index.tsx', // Point to main file
11 path: path.resolve(process.cwd(), 'dist'),
12 filename: 'js/server.js',
16 extensions: ['.js', '.jsx', '.ts', '.tsx'],
24 test: /\.(scss|css)$/i,
25 use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader'],
28 test: /\.(js|jsx|tsx|ts)$/, // All ts and tsx files will be process by
29 loaders: 'babel-loader', // first babel-loader, then ts-loader
30 exclude: /node_modules/, // ignore node_modules
37 historyApiFallback: true,
40 new MiniCssExtractPlugin({
41 filename: 'styles/styles.css',
46 // server-specific configuration
47 if (env.platform === 'server') {
49 base.externals = [nodeExternals()];
51 // client-specific configurations
52 if (env.platform === 'client') {
53 base.entry = './src/client/index.tsx';
54 base.output.filename = 'js/client.js';