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,
26 MiniCssExtractPlugin.loader,
29 loader: 'postcss-loader', // Run post css actions
31 plugins: function () {
32 // post css plugins, can be exported to postcss.config.js
33 return [require('precss'), require('autoprefixer')];
41 test: /\.(js|jsx|tsx|ts)$/, // All ts and tsx files will be process by
42 loaders: 'babel-loader', // first babel-loader, then ts-loader
43 exclude: /node_modules/, // ignore node_modules
50 historyApiFallback: true,
53 new MiniCssExtractPlugin({
54 filename: 'styles/styles.css',
59 // server-specific configuration
60 if (env.platform === 'server') {
62 base.externals = [nodeExternals()];
64 // client-specific configurations
65 if (env.platform === 'client') {
66 base.entry = './src/client/index.tsx';
67 base.output.filename = 'js/client.js';