/* * Copyright 2024 Adobe. All rights reserved. * This file is licensed to you under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. You may obtain a copy * of the License at http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS * OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ const path = require('path'); const HtmlWebpackPlugin = require('html-webpack-plugin'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); const CssMinimizerPlugin = require('css-minimizer-webpack-plugin'); const {SwcMinifyWebpackPlugin} = require('swc-minify-webpack-plugin'); const {browserslistToTargets} = require('lightningcss'); const browserslist = require('browserslist'); const macros = require('unplugin-parcel-macros'); // Adjust this to target the browsers your product supports. // https://browserslist.dev/ const BROWSERSLIST = 'last 2 Chrome versions, last 2 Safari versions, last 2 Firefox versions'; module.exports = (env, argv) => ({ entry: path.join(__dirname, 'src', 'index.js'), output: { path: path.resolve(__dirname, 'dist') }, mode: argv.mode || 'development', module: { rules: [ { // Use SWC to compile JSX. You could also use babel-loader instead. test: /\.?js$/, exclude: /node_modules/, use: { loader: 'swc-loader', options: { env: { targets: BROWSERSLIST }, jsc: { parser: { jsx: true } } } } }, { // Use mini-css-extract-plugin instead of style-loader to that CSS is extracted // into a standalone .css bundle instead of inlined into JS via