webpack.common.js 1.6 KB

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