|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +const path = require('path'); |
| 4 | +const webpack = require('webpack'); |
| 5 | + |
| 6 | +const { LocalizationPlugin } = require('@rushstack/localization-plugin'); |
| 7 | +const { SetPublicPathPlugin } = require('@microsoft/set-webpack-public-path-plugin'); |
| 8 | +const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer'); |
| 9 | +const HtmlWebpackPlugin = require('html-webpack-plugin'); |
| 10 | + |
| 11 | +module.exports = function(env) { |
| 12 | + const configuration = { |
| 13 | + mode: 'production', |
| 14 | + module: { |
| 15 | + rules: [ |
| 16 | + { |
| 17 | + test: /\.tsx?$/, |
| 18 | + loader: require.resolve('ts-loader'), |
| 19 | + exclude: /(node_modules)/, |
| 20 | + options: { |
| 21 | + compiler: require.resolve('@microsoft/rush-stack-compiler-3.5/node_modules/typescript'), |
| 22 | + logLevel: 'ERROR', |
| 23 | + configFile: path.resolve(__dirname, 'tsconfig.json') |
| 24 | + } |
| 25 | + } |
| 26 | + ] |
| 27 | + }, |
| 28 | + resolve: { |
| 29 | + extensions: ['.js', '.jsx', '.json', '.ts', '.tsx'] |
| 30 | + }, |
| 31 | + entry: { |
| 32 | + 'localization-test-A': path.join(__dirname, 'src', 'indexA.ts'), |
| 33 | + 'localization-test-B': path.join(__dirname, 'src', 'indexB.ts'), |
| 34 | + }, |
| 35 | + output: { |
| 36 | + path: path.join(__dirname, 'dist'), |
| 37 | + filename: '[name]_[locale]_[contenthash].js', |
| 38 | + chunkFilename: '[id].[name]_[locale]_[contenthash].js' |
| 39 | + }, |
| 40 | + optimization: { |
| 41 | + minimize: false |
| 42 | + }, |
| 43 | + plugins: [ |
| 44 | + new webpack.optimize.ModuleConcatenationPlugin(), |
| 45 | + new LocalizationPlugin({ |
| 46 | + localizedStrings: {}, |
| 47 | + defaultLocale: { |
| 48 | + usePassthroughLocale: true |
| 49 | + }, |
| 50 | + localizationStatsDropPath: path.resolve(__dirname, 'temp', 'localization-stats.json') |
| 51 | + }), |
| 52 | + new BundleAnalyzerPlugin({ |
| 53 | + openAnalyzer: false, |
| 54 | + analyzerMode: 'static', |
| 55 | + reportFilename: path.resolve(__dirname, 'temp', 'stats.html'), |
| 56 | + generateStatsFile: true, |
| 57 | + statsFilename: path.resolve(__dirname, 'temp', 'stats.json'), |
| 58 | + logLevel: 'error' |
| 59 | + }), |
| 60 | + new SetPublicPathPlugin({ |
| 61 | + scriptName: { |
| 62 | + name: '[name]_[locale]_[contenthash].js', |
| 63 | + isTokenized: true |
| 64 | + } |
| 65 | + }), |
| 66 | + new HtmlWebpackPlugin() |
| 67 | + ] |
| 68 | + }; |
| 69 | + |
| 70 | + return configuration; |
| 71 | +} |
0 commit comments