webpack.base.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. var path = require('path');
  2. const { VueLoaderPlugin } = require('vue-loader');
  3. const ESLintPlugin = require('eslint-webpack-plugin');
  4. const MiniCssExtractPlugin = require('mini-css-extract-plugin');
  5. module.exports = {
  6. module: {
  7. rules: [
  8. {
  9. test: /\.vue$/,
  10. loader: 'vue-loader',
  11. },
  12. {
  13. test: /\.js$/,
  14. loader: 'babel-loader',
  15. // include: [
  16. // path.resolve(__dirname, './node_modules/pc-component-v3/dist/pc-component-v3.js'),
  17. // ],
  18. exclude: /node_modules/,
  19. // exclude: file => (
  20. // /node_modules/.test(file) &&
  21. // !/\.vue\.js/.test(file)
  22. // ),
  23. },
  24. {
  25. test: /\.css$/,
  26. use: (process.env.NODE_ENV === 'production') ? [
  27. {
  28. loader: MiniCssExtractPlugin.loader,
  29. options: {
  30. publicPath: '../',
  31. },
  32. },
  33. 'css-loader'] : ['style-loader', 'css-loader'],
  34. },
  35. {
  36. test: /\.(json5?|ya?ml)$/, // target json, json5, yaml and yml files
  37. type: 'javascript/auto',
  38. loader: '@intlify/vue-i18n-loader',
  39. include: [ // Use `Rule.include` to specify the files of locale messages to be pre-compiled
  40. //path.resolve(__dirname, 'src/locales'),
  41. path.resolve(__dirname, 'client-base-v3/src/locales'),
  42. path.resolve(__dirname, 'client-wms-v3/src/locales'),
  43. path.resolve(__dirname, 'client-role-v3/src/locales'),
  44. ],
  45. },
  46. {
  47. // webpack5 通过资源模块来处理图片
  48. test: /\.(png|jpg|gif|svg)$/,
  49. type: 'asset/resource',
  50. parser: {
  51. dataUrlCondition: {
  52. maxSize: 10240,
  53. },
  54. },
  55. generator: {
  56. filename: './client-base-v3-image/[name][ext][query]',
  57. },
  58. },
  59. {
  60. test: /\.(eot|woff|woff2|ttf)$/,
  61. type: 'asset/resource',
  62. generator: {
  63. filename: './client-base-v3-font/[name].[ext]?[hash]',
  64. },
  65. },
  66. ],
  67. },
  68. resolve: {
  69. alias: {
  70. },
  71. extensions: ['*', '.js', '.vue', '.json'],
  72. },
  73. performance: {
  74. hints: false,
  75. },
  76. externals: {
  77. 'jquery': "window.jquery",
  78. 'bootstrap': 'bootstrap',
  79. 'BootstrapDialog': 'BootstrapDialog',
  80. 'vue': 'Vue',
  81. 'vue-i18n': 'VueI18n',
  82. 'vue-router': 'VueRouter',
  83. 'vuex': 'Vuex',
  84. 'dayjs': 'dayjs',
  85. },
  86. plugins: [
  87. new VueLoaderPlugin(),
  88. new ESLintPlugin({
  89. extensions: ['js', 'vue'],
  90. // 自动修复。
  91. // 自从eslint推出--fix命令后,如果觉得eslint格式化规则已经够用的话,其实也可以不用prettier了。
  92. fix: true,
  93. }),
  94. ],
  95. };