webpack.conf.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. },
  21. resolve: {
  22. extensions: ['.js', '.vue', '.json'],
  23. alias: config.alias
  24. },
  25. externals: {
  26. vue: config.vue
  27. },
  28. optimization: {
  29. minimizer: [
  30. new TerserPlugin({
  31. terserOptions: {
  32. output: {
  33. comments: false
  34. }
  35. },
  36. })
  37. ]
  38. },
  39. performance: {
  40. hints: false
  41. },
  42. stats: {
  43. children: false
  44. },
  45. module: {
  46. rules: [
  47. {
  48. test: /\.(jsx?|babel|es6)$/,
  49. include: process.cwd(),
  50. exclude: config.jsexclude,
  51. loader: 'babel-loader'
  52. },
  53. {
  54. test: /\.vue$/,
  55. loader: 'vue-loader',
  56. options: {
  57. compilerOptions: {
  58. preserveWhitespace: false
  59. }
  60. }
  61. },
  62. {
  63. test: /\.css$/,
  64. loaders: ['style-loader', 'css-loader', 'postcss-loader']
  65. },
  66. {
  67. test: /\.scss$/,
  68. loaders: ['style-loader', 'css-loader', 'sass-loader']
  69. },
  70. {
  71. test: /\.(svg|otf|ttf|woff2?|eot|gif|png|jpe?g)(\?\S*)?$/,
  72. loader: 'url-loader',
  73. query: {
  74. limit: 10000,
  75. name: path.posix.join('static', '[name].[hash:7].[ext]')
  76. }
  77. }
  78. ]
  79. },
  80. plugins: [
  81. new ProgressBarPlugin(),
  82. new VueLoaderPlugin()
  83. ]
  84. };