webpack.conf.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. const path = require('path');
  2. const ProgressBarPlugin = require('progress-bar-webpack-plugin');
  3. const VueLoaderPlugin = require('vue-loader/lib/plugin');
  4. const config = require('./config');
  5. module.exports = {
  6. mode: 'production',
  7. entry: {
  8. app: ['./src/index.js']
  9. },
  10. output: {
  11. path: path.resolve(process.cwd(), './lib'),
  12. publicPath: '/dist/',
  13. filename: 'index.js',
  14. chunkFilename: '[id].js',
  15. libraryTarget: 'umd',
  16. libraryExport: 'default',
  17. library: 'ELEMENT',
  18. umdNamedDefine: true
  19. },
  20. resolve: {
  21. extensions: ['.js', '.vue', '.json'],
  22. alias: config.alias
  23. },
  24. externals: {
  25. vue: config.vue
  26. },
  27. performance: {
  28. hints: false
  29. },
  30. stats: {
  31. children: false
  32. },
  33. module: {
  34. rules: [
  35. {
  36. test: /\.(jsx?|babel|es6)$/,
  37. include: process.cwd(),
  38. exclude: config.jsexclude,
  39. loader: 'babel-loader'
  40. },
  41. {
  42. test: /\.vue$/,
  43. loader: 'vue-loader',
  44. options: {
  45. compilerOptions: {
  46. preserveWhitespace: false
  47. }
  48. }
  49. },
  50. {
  51. test: /\.css$/,
  52. loaders: ['style-loader', 'css-loader', 'postcss-loader']
  53. },
  54. {
  55. test: /\.scss$/,
  56. loaders: ['style-loader', 'css-loader', 'sass-loader']
  57. },
  58. {
  59. test: /\.(svg|otf|ttf|woff2?|eot|gif|png|jpe?g)(\?\S*)?$/,
  60. loader: 'url-loader',
  61. query: {
  62. limit: 10000,
  63. name: path.posix.join('static', '[name].[hash:7].[ext]')
  64. }
  65. }
  66. ]
  67. },
  68. plugins: [
  69. new ProgressBarPlugin(),
  70. new VueLoaderPlugin()
  71. ]
  72. };