webpack.config.js 862 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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: 'buried-piont',
  11. type: 'umd',
  12. },
  13. globalObject: 'this',
  14. },
  15. mode: 'production',
  16. module: {
  17. rules: [
  18. {
  19. test: /\.css$/,
  20. use: [
  21. 'style-loader',
  22. 'css-loader'
  23. ]
  24. },
  25. {
  26. test: /\.js$/,
  27. exclude: /node_modules/,
  28. use: {
  29. loader: 'babel-loader',
  30. options: {
  31. presets: ['@babel/preset-env'],
  32. },
  33. },
  34. },
  35. ],
  36. },
  37. optimization: {
  38. minimizer: [new TerserPlugin()],
  39. },
  40. plugins: [new CleanWebpackPlugin()],
  41. };