1 const MiniCssExtractPlugin = require('mini-css-extract-plugin');
2 const nodeExternals = require('webpack-node-externals');
3 const CopyPlugin = require('copy-webpack-plugin');
4 const path = require('path');
6 module.exports = function (env, _) {
8 // mode is set by package.json flags
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',
44 patterns: [{ from: './src/assets', to: './assets' }],
49 // server-specific configuration
50 if (env.platform === 'server') {
52 base.externals = [nodeExternals()];
54 // client-specific configurations
55 if (env.platform === 'client') {
56 base.entry = './src/client/index.tsx';
57 base.output.filename = 'js/client.js';