Skip to content

Instantly share code, notes, and snippets.

@siddharthvp
Created December 30, 2021 09:26
Show Gist options
  • Save siddharthvp/1ba1e0791bd8c80eb5e93ae7a41ff44e to your computer and use it in GitHub Desktop.
Save siddharthvp/1ba1e0791bd8c80eb5e93ae7a41ff44e to your computer and use it in GitHub Desktop.
Webpack configuration to transpile banana-i18n to ES5
// Webpack configuration to transpile banana-i18n to ES5. Run:
// $ npm i -D webpack webpack-cli @babel/core @babel/preset-env babel-loader
// $ npx webpack
// Find output in dist/banana-i18n.js
const path = require('path')
const TerserPlugin = require('terser-webpack-plugin')
module.exports = {
mode: 'production',
entry: './src/index.js',
target: ['web', 'es5'],
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
}
]
},
optimization: {
minimizer: [
new TerserPlugin({
// terserOptions: { output: { ascii_only: true } }
})
]
},
output: {
library: 'Banana',
libraryExport: 'default',
libraryTarget: 'umd',
globalObject: 'this',
filename: 'banana-i18n.js',
path: path.resolve(__dirname, 'dist')
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment