zorkow | c1850b8 | 2021-05-10 21:57:37 +0100 | [diff] [blame] | 1 | const path = require('path'); |
| 2 | const TerserPlugin = require('terser-webpack-plugin'); |
zorkow | 2b912ac | 2021-09-10 17:02:36 +0200 | [diff] [blame^] | 3 | const CircularDependencyPlugin = require('circular-dependency-plugin'); |
| 4 | |
zorkow | c1850b8 | 2021-05-10 21:57:37 +0100 | [diff] [blame] | 5 | |
| 6 | let config = { |
| 7 | module: { |
| 8 | rules: [ |
| 9 | { |
| 10 | test: /\.tsx?$/, |
| 11 | use: 'ts-loader', |
| 12 | exclude: /node_modules|src/, |
| 13 | } |
| 14 | ], |
| 15 | }, |
| 16 | resolve: { |
| 17 | extensions: [ '.tsx', '.ts', '.js' ], |
| 18 | }, |
| 19 | node: { |
| 20 | __dirname: false |
| 21 | }, |
zorkow | 2b912ac | 2021-09-10 17:02:36 +0200 | [diff] [blame^] | 22 | plugins: [ |
| 23 | new CircularDependencyPlugin({ |
| 24 | // exclude detection of files based on a RegExp |
| 25 | exclude: /a\.js|node_modules/, |
| 26 | // add errors to webpack instead of warnings |
| 27 | failOnError: false, |
| 28 | // allow import cycles that include an asyncronous import, |
| 29 | // e.g. via import(/* webpackMode: "weak" */ './file.js') |
| 30 | allowAsyncCycles: false, |
| 31 | // set the current working directory for displaying module paths |
| 32 | cwd: process.cwd(), |
| 33 | }) |
| 34 | ], |
zorkow | c1850b8 | 2021-05-10 21:57:37 +0100 | [diff] [blame] | 35 | optimization: { |
| 36 | minimize: true, |
| 37 | minimizer: [new TerserPlugin({ |
| 38 | terserOptions: { |
| 39 | output: { |
| 40 | ascii_only: true |
| 41 | } |
| 42 | } |
| 43 | })] |
| 44 | }, |
| 45 | mode: 'production' |
| 46 | }; |
| 47 | |
| 48 | let sreConfig = Object.assign({}, config, { |
| 49 | entry: path.resolve(__dirname, 'ts/index.ts'), |
| 50 | // devtool: false, |
| 51 | // target: 'web', |
| 52 | output: { |
| 53 | filename: 'sre.js', |
| 54 | library: 'SRE', |
| 55 | libraryTarget: 'umd', |
| 56 | globalObject: 'this', |
| 57 | path: path.join(__dirname, 'lib'), |
| 58 | } |
| 59 | }); |
| 60 | |
zorkow | fb54695 | 2021-05-19 11:53:22 +0100 | [diff] [blame] | 61 | let mjConfig = Object.assign({}, config, { |
| 62 | entry: path.resolve(__dirname, 'ts/common/mathjax.ts'), |
| 63 | // devtool: false, |
| 64 | target: 'web', |
| 65 | output: { |
| 66 | filename: 'mathjax-sre.js', |
| 67 | library: 'MJ', |
| 68 | libraryTarget: 'umd', |
| 69 | globalObject: 'this', |
| 70 | path: path.join(__dirname, 'lib'), |
| 71 | } |
| 72 | }); |
| 73 | |
zorkow | c1850b8 | 2021-05-10 21:57:37 +0100 | [diff] [blame] | 74 | module.exports = [sreConfig]; |