const path = require('path'); const webpack = require('webpack'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); const TerserJSPlugin = require('terser-webpack-plugin'); const config = { entry: { editor: './editor/index.js', }, output: { filename: '[name].js', path: path.resolve(__dirname, 'web/static'), }, module: { rules: [ { test: /\.(js|mjs)$/, exclude: /node_modules/, loader: 'babel-loader', }, { test: /\.scss|\.css$/, use: [ { loader: MiniCssExtractPlugin.loader, }, 'css-loader', 'sass-loader', ], }, ], }, externals: { react: 'React', 'react-dom': 'ReactDOM', }, plugins: [ new webpack.DefinePlugin({ 'process.env': {NODE_ENV: JSON.stringify(process.env.NODE_ENV || 'development')}, }), new MiniCssExtractPlugin({ filename: '[name].css', }), ], optimization: { minimizer: [new TerserJSPlugin()], }, }; module.exports = config;