webpack.base.js 2.7 KB

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