83 lines
1.3 KiB
JavaScript
83 lines
1.3 KiB
JavaScript
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
|
|
}
|
|
}] |