const path = require('path'); const webpack = require('webpack'); const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin; const SemiWebpackPlugin = require('@douyinfe/semi-webpack-plugin').default; const PATHS = { app: path.join(__dirname, 'client/src'), build: path.join(__dirname, 'client/build') }; module.exports = { mode: "development", devtool: 'source-map', devServer: { historyApiFallback: true, // 为 MicroApp 配置跨域 // 'Access-Control-Allow-Origin': '*', // allowedHosts: ['127.0.0.1:5100'], }, entry: { app: ["@babel/polyfill", PATHS.app] }, output: { publicPath: '/client/build/', path: PATHS.build, filename: '[name].js' }, resolve: { modules: [path.resolve(__dirname, 'client/src'), path.resolve(__dirname, 'node_modules')], extensions: ['.js', '.jsx'], alias: { crypto: false, $utils: path.resolve(__dirname, 'client/src/utils/'), $components: path.resolve(__dirname, 'client/src/components/'), } }, plugins: [ new webpack.HotModuleReplacementPlugin(), new BundleAnalyzerPlugin({ analyzerPort: 8700, }), new SemiWebpackPlugin({ theme: { name: '@semi-bot/semi-theme-fscamera', include: '~@semi-bot/semi-theme-fscamera/scss/local.scss' } }), ], module: { rules: [{ test: /\.css$/, use: ['style-loader', { loader: 'css-loader', options: { modules: true } }] }, { test: /\.less$/, use: ['style-loader', 'css-loader', { loader: 'less-loader', options: { lessOptions: { javascriptEnabled: true } } }] }, { test: /\.(js|jsx)$/, use: 'babel-loader', include: [PATHS.app, path.resolve(__dirname, 'node_modules', '@peace')], }, { test: /\.(eot|woff|woff2|svg|ttf)([\?]?.*)$/, loader: "file-loader" } ] } };