Created
December 30, 2021 09:26
-
-
Save siddharthvp/1ba1e0791bd8c80eb5e93ae7a41ff44e to your computer and use it in GitHub Desktop.
Webpack configuration to transpile banana-i18n to ES5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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