Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const path = require('path');
- const webpack = require('webpack');
- const TerserPlugin = require('terser-webpack-plugin');
- const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
- module.exports = {
- entry: './src/min-babylon.ts',
- output: {
- filename: 'babylon.custom.min.js',
- path: path.resolve(__dirname, 'scripts'),
- library: 'BABYLON',
- libraryTarget: 'window',
- clean: false,
- chunkFilename: '[id].babylon.custom.min.js'
- },
- mode: 'production',
- target: ['web', 'es2018'],
- devtool: false,
- resolve: {
- extensions: ['.ts', '.js'],
- mainFields: ['module', 'browser', 'main'],
- fallback: {}
- },
- module: {
- rules: [
- {
- test: /\.ts$/,
- use: [{ loader: 'ts-loader', options: { transpileOnly: true } }],
- exclude: /node_modules/
- }
- ]
- },
- optimization: {
- minimize: true,
- usedExports: true,
- sideEffects: true,
- concatenateModules: true,
- mangleExports: 'size',
- // restore default async chunking (working setup)
- splitChunks: { chunks: 'async' },
- runtimeChunk: false,
- minimizer: [
- new TerserPlugin({
- parallel: true,
- terserOptions: {
- ecma: 2018,
- compress: {
- passes: 2,
- pure_getters: true,
- unsafe_arrows: true,
- unsafe_methods: true,
- dead_code: true,
- drop_console: true
- },
- mangle: {
- safari10: false
- },
- format: {
- comments: false
- },
- keep_classnames: false,
- keep_fnames: false
- }
- })
- ]
- },
- plugins: [
- ...(process.env.ANALYZE ? [new BundleAnalyzerPlugin({ analyzerMode: 'static', openAnalyzer: false, reportFilename: 'webpack-report.html' })] : [])
- ],
- experiments: {
- backCompat: false
- },
- performance: {
- hints: false
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment