webpack.base.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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-v4/src/locales'),
  42. path.resolve(__dirname, 'client-eam-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-v4-image/[name][ext][query]',
  57. },
  58. },
  59. {
  60. test: /\.(eot|woff|woff2|ttf)$/,
  61. type: 'asset/resource',
  62. generator: {
  63. filename: './client-v4-font/[name].[ext]?[hash]',
  64. },
  65. },
  66. ],
  67. },
  68. resolve: {
  69. alias: {
  70. // 'vue$': 'vue/dist/vue.esm.js',
  71. '@static': path.resolve('static'),
  72. },
  73. extensions: ['*', '.js', '.vue', '.json'],
  74. },
  75. performance: {
  76. hints: false,
  77. },
  78. externals: {
  79. jquery: 'window.jquery',
  80. bootstrap: 'bootstrap',
  81. BootstrapDialog: 'BootstrapDialog',
  82. d3: 'd3',
  83. echarts: 'echarts',
  84. moment: 'moment',
  85. 'vue': 'Vue',
  86. 'vue-i18n': 'VueI18n',
  87. 'vue-router': 'VueRouter',
  88. 'vuex': 'Vuex',
  89. 'Vuex': 'Vuex',
  90. '@antv/x6': 'X6',
  91. 'X6': 'X6',
  92. 'axios': 'axios',
  93. 'sortablejs': 'Sortable',
  94. // 'gantt': 'gantt'
  95. },
  96. plugins: [
  97. new VueLoaderPlugin(),
  98. // new ESLintPlugin({
  99. // extensions: ['js', 'vue'],
  100. // // 自动修复。
  101. // // 自从eslint推出--fix命令后,如果觉得eslint格式化规则已经够用的话,其实也可以不用prettier了。
  102. // fix: true,
  103. // }),
  104. ],
  105. };