webpack.conf.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. const path = require('path');
  2. const webpack = require('webpack');
  3. const ProgressBarPlugin = require('progress-bar-webpack-plugin');
  4. const config = require('./config');
  5. module.exports = {
  6. entry: {
  7. app: ['./src/index.js']
  8. },
  9. output: {
  10. path: path.resolve(process.cwd(), './lib'),
  11. publicPath: '/dist/',
  12. filename: 'index.js',
  13. chunkFilename: '[id].js',
  14. libraryTarget: 'umd',
  15. library: 'ELEMENT',
  16. umdNamedDefine: true
  17. },
  18. resolve: {
  19. extensions: ['.js', '.vue', '.json'],
  20. alias: config.alias
  21. },
  22. externals: {
  23. vue: config.vue
  24. },
  25. module: {
  26. rules: [
  27. {
  28. test: /\.(jsx?|babel|es6)$/,
  29. include: process.cwd(),
  30. exclude: config.jsexclude,
  31. loader: 'babel-loader'
  32. },
  33. {
  34. test: /\.vue$/,
  35. loader: 'vue-loader',
  36. options: {
  37. preserveWhitespace: false
  38. }
  39. },
  40. {
  41. test: /\.json$/,
  42. loader: 'json-loader'
  43. },
  44. {
  45. test: /\.css$/,
  46. loaders: ['style-loader', 'css-loader', 'postcss-loader']
  47. },
  48. {
  49. test: /\.scss$/,
  50. loaders: ['style-loader', 'css-loader', 'sass-loader']
  51. },
  52. {
  53. test: /\.html$/,
  54. loader: 'html-loader?minimize=false'
  55. },
  56. {
  57. test: /\.otf|ttf|woff2?|eot(\?\S*)?$/,
  58. loader: 'url-loader',
  59. query: {
  60. limit: 10000,
  61. name: path.posix.join('static', '[name].[hash:7].[ext]')
  62. }
  63. },
  64. {
  65. test: /\.svg(\?\S*)?$/,
  66. loader: 'url-loader',
  67. query: {
  68. limit: 10000,
  69. name: path.posix.join('static', '[name].[hash:7].[ext]')
  70. }
  71. },
  72. {
  73. test: /\.(gif|png|jpe?g)(\?\S*)?$/,
  74. loader: 'url-loader',
  75. query: {
  76. limit: 10000,
  77. name: path.posix.join('static', '[name].[hash:7].[ext]')
  78. }
  79. }
  80. ]
  81. },
  82. plugins: [
  83. new ProgressBarPlugin(),
  84. new webpack.DefinePlugin({
  85. 'process.env.NODE_ENV': JSON.stringify('production')
  86. }),
  87. new webpack.optimize.UglifyJsPlugin({
  88. compress: {
  89. warnings: false
  90. },
  91. output: {
  92. comments: false
  93. },
  94. sourceMap: false
  95. }),
  96. new webpack.LoaderOptionsPlugin({
  97. minimize: true
  98. })
  99. ]
  100. };