webpack.component.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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']
  49. },
  50. {
  51. test: /\.(svg|otf|ttf|woff2?|eot|gif|png|jpe?g)(\?\S*)?$/,
  52. loader: 'url-loader',
  53. query: {
  54. limit: 10000,
  55. name: path.posix.join('static', '[name].[hash:7].[ext]')
  56. }
  57. }
  58. ]
  59. },
  60. plugins: [
  61. new ProgressBarPlugin(),
  62. new VueLoaderPlugin()
  63. ]
  64. };
  65. module.exports = webpackConfig;