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