webpack.conf.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. const path = require('path');
  2. const ProgressBarPlugin = require('progress-bar-webpack-plugin');
  3. const VueLoaderPlugin = require('vue-loader/lib/plugin');
  4. const TerserPlugin = require('terser-webpack-plugin');
  5. const config = require('./config');
  6. module.exports = {
  7. mode: 'production',
  8. entry: {
  9. app: ['./src/index.js']
  10. },
  11. output: {
  12. path: path.resolve(process.cwd(), './lib'),
  13. publicPath: '/dist/',
  14. filename: 'index.js',
  15. chunkFilename: '[id].js',
  16. libraryTarget: 'umd',
  17. libraryExport: 'default',
  18. library: 'ELEMENT',
  19. umdNamedDefine: true,
  20. globalObject: 'typeof self !== \'undefined\' ? self : this'
  21. },
  22. resolve: {
  23. extensions: ['.js', '.vue', '.json'],
  24. alias: config.alias
  25. },
  26. externals: {
  27. vue: config.vue
  28. },
  29. optimization: {
  30. minimizer: [
  31. new TerserPlugin({
  32. terserOptions: {
  33. output: {
  34. comments: false
  35. }
  36. }
  37. })
  38. ]
  39. },
  40. performance: {
  41. hints: false
  42. },
  43. stats: {
  44. children: false
  45. },
  46. module: {
  47. rules: [
  48. {
  49. test: /\.(jsx?|babel|es6)$/,
  50. include: process.cwd(),
  51. exclude: config.jsexclude,
  52. loader: 'babel-loader'
  53. },
  54. {
  55. test: /\.vue$/,
  56. loader: 'vue-loader',
  57. options: {
  58. compilerOptions: {
  59. preserveWhitespace: false
  60. }
  61. }
  62. }
  63. ]
  64. },
  65. plugins: [
  66. new ProgressBarPlugin(),
  67. new VueLoaderPlugin()
  68. ]
  69. };