webpack.config.js 746 B

1234567891011121314151617181920212223242526272829303132333435
  1. const path = require('path');
  2. const { CleanWebpackPlugin } = require('clean-webpack-plugin');
  3. const TerserPlugin = require('terser-webpack-plugin');
  4. module.exports = {
  5. entry: './src/index.js',
  6. output: {
  7. path: path.resolve(__dirname, 'dist'),
  8. filename: 'main.js',
  9. library: {
  10. name: 'yourLibrary',
  11. type: 'umd',
  12. },
  13. globalObject: 'this',
  14. },
  15. mode: 'production',
  16. module: {
  17. rules: [
  18. {
  19. test: /\.js$/,
  20. exclude: /node_modules/,
  21. use: {
  22. loader: 'babel-loader',
  23. options: {
  24. presets: ['@babel/preset-env'],
  25. },
  26. },
  27. },
  28. ],
  29. },
  30. optimization: {
  31. minimizer: [new TerserPlugin()],
  32. },
  33. plugins: [new CleanWebpackPlugin()],
  34. };