const path = require('path'); const SizePlugin = require('size-plugin'); const CopyWebpackPlugin = require('copy-webpack-plugin'); const WebExtWebpackPlugin = require('@ianwalter/web-ext-webpack-plugin'); const TerserPlugin = require('terser-webpack-plugin'); module.exports = { devtool: 'source-map', stats: 'errors-only', entry: { background: './src/background', popup: './src/popup', }, output: { path: path.join(__dirname, 'dist'), filename: '[name].js' }, module: { rules: [ { test: /\.js$/, include: [ path.resolve(__dirname, "src") ], use: { loader: 'babel-loader', options: { presets: [ ["@babel/preset-env", { modules: false }], "@babel/preset-react" ], plugins: [ "@babel/plugin-transform-react-constant-elements", "@babel/plugin-proposal-object-rest-spread", "@babel/plugin-proposal-class-properties", "@babel/plugin-transform-runtime", ], }, }, }, { test: /\.(svg|gif|png|jpg)$/, use: 'url-loader', } ], }, plugins: [ new SizePlugin(), new CopyWebpackPlugin([ { from: '**/*', context: 'public', }, { from: 'node_modules/webextension-polyfill/dist/browser-polyfill.min.js' } ]), new WebExtWebpackPlugin({ sourceDir: path.join(__dirname, 'dist'), verbose: true }), ], optimization: { minimizer: [ new TerserPlugin({ terserOptions: { mangle: false, compress: false, output: { beautify: true, indent_level: 2 // eslint-disable-line camelcase } } }) ] } };