webpack.base.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. // include: [
  17. // path.resolve(__dirname, './node_modules/pc-component-v3/dist/pc-component-v3.js'),
  18. // ],
  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. // webpack5 通过资源模块来处理图片
  37. test: /\.(png|jpg|gif|svg)$/,
  38. type: 'asset',
  39. parser: {
  40. dataUrlCondition: {
  41. maxSize: 10240
  42. }
  43. },
  44. generator: {
  45. filename: './eam-app-v3-image/[name][ext][query]'
  46. }
  47. },
  48. {
  49. test: /\.(eot|woff|woff2|ttf)$/,
  50. loader: 'file-loader',
  51. options: {
  52. name: './eam-app-v3-font/[name].[ext]?[hash]'
  53. }
  54. },
  55. ]
  56. },
  57. resolve: {
  58. alias: {
  59. // 'vue$': 'vue/dist/vue.esm.js',
  60. '@static': path.resolve('static-eam-app'),
  61. },
  62. extensions: ['*', '.js', '.vue', '.json']
  63. },
  64. performance: {
  65. hints: false
  66. },
  67. externals: {
  68. jQuery: 'window.$',
  69. jquery: 'window.$',
  70. bootstrap: 'bootstrap',
  71. BootstrapDialog: 'BootstrapDialog',
  72. d3: 'd3',
  73. echarts: 'echarts',
  74. moment: 'moment',
  75. },
  76. plugins: [
  77. new VueLoaderPlugin(),
  78. new ESLintPlugin({
  79. extensions: ['js', 'vue'],
  80. // 自动修复。
  81. // 自从eslint推出--fix命令后,如果觉得eslint格式化规则已经够用的话,其实也可以不用prettier了。
  82. fix: true,
  83. }),
  84. ]
  85. }