webpack.common.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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: 'element-ui.common.js',
  14. chunkFilename: '[id].js',
  15. libraryExport: 'default',
  16. library: 'ELEMENT',
  17. libraryTarget: 'commonjs2'
  18. },
  19. resolve: {
  20. extensions: ['.js', '.vue', '.json'],
  21. alias: config.alias,
  22. modules: ['node_modules']
  23. },
  24. externals: config.externals,
  25. performance: {
  26. hints: false
  27. },
  28. stats: {
  29. children: false
  30. },
  31. optimization: {
  32. minimize: false
  33. },
  34. module: {
  35. rules: [
  36. {
  37. test: /\.(jsx?|babel|es6)$/,
  38. include: process.cwd(),
  39. exclude: config.jsexclude,
  40. loader: 'babel-loader'
  41. },
  42. {
  43. test: /\.vue$/,
  44. loader: 'vue-loader',
  45. options: {
  46. compilerOptions: {
  47. preserveWhitespace: false
  48. }
  49. }
  50. },
  51. {
  52. test: /\.css$/,
  53. loaders: ['style-loader', 'css-loader', 'postcss-loader']
  54. },
  55. {
  56. test: /\.scss$/,
  57. loaders: ['style-loader', 'css-loader', 'sass-loader']
  58. },
  59. {
  60. test: /\.(svg|otf|ttf|woff2?|eot|gif|png|jpe?g)(\?\S*)?$/,
  61. loader: 'url-loader',
  62. query: {
  63. limit: 10000,
  64. name: path.posix.join('static', '[name].[hash:7].[ext]')
  65. }
  66. }
  67. ]
  68. },
  69. plugins: [
  70. new ProgressBarPlugin(),
  71. new VueLoaderPlugin()
  72. ]
  73. };