webpack.component.js 1.6 KB

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