const path = require('path') const build = env => ({ mode: 'production', entry: './src/index.ts', module: { rules: [{ test: /\.ts$/, use: { loader: 'ts-loader', options: { compilerOptions: { module: 'esnext', paths: { '%env%': [`./src/env/${env}`] } } } }, exclude: /node_modules/ }], }, resolve: { alias: { '%env%': path.resolve(__dirname, `src/env/${env}`) }, extensions: [ '.ts', '.js' ] }, }) module.exports = [{ // prebuilt binary, for browser usage ...build('web'), output: { library: { name: 'Sati', type: 'umd' }, filename: `sati.web.umd.js` } }, { // prebuilt binary with external dependencies, for browser usage with bundlers ...build('web'), output: { library: { type: 'module' }, filename: `sati.web.esm.js` }, externals: /^[^\.%]/, experiments: { outputModule: true } }, { // prebuilt node version ...build('node'), output: { library: { type: 'commonjs2' }, filename: `sati.node.cjs.js` }, externals: /^[^\.%]/, optimization: { minimize: false } }, { // prebuilt node esm version ...build('node'), output: { library: { type: 'module' }, filename: 'sati.node.esm.mjs' }, externals: /^[^\.%]/, optimization: { minimize: false }, experiments: { outputModule: true } }]