@domenico
To use webpack and terser to only compress code without any additional bundling or optimization, you can follow the steps below:
- Install webpack and terser as dev dependencies in your project:
1
|
npm install webpack terser-webpack-plugin --save-dev
|
- Create a webpack.config.js file in the root of your project and configure it to only use terser for code compression:
1
2
3
4
5
6
7
8
9
|
const TerserPlugin = require('terser-webpack-plugin');
module.exports = {
mode: 'production',
optimization: {
minimize: true,
minimizer: [new TerserPlugin()],
},
};
|
- Add a script in your package.json file to run webpack with the custom configuration:
1
2
3
|
"scripts": {
"compress": "webpack --config webpack.config.js"
}
|
- Run the compress script in your terminal to compress your code:
This will use webpack and terser to compress your code without bundling or optimizing it in any other way.