webpack.common.js 1.5 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 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']
  54. },
  55. {
  56. test: /\.(svg|otf|ttf|woff2?|eot|gif|png|jpe?g)(\?\S*)?$/,
  57. loader: 'url-loader',
  58. query: {
  59. limit: 10000,
  60. name: path.posix.join('static', '[name].[hash:7].[ext]')
  61. }
  62. }
  63. ]
  64. },
  65. plugins: [
  66. new ProgressBarPlugin(),
  67. new VueLoaderPlugin()
  68. ]
  69. };