webpack.component.js 2.1 KB

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