停车场项目web, 互联网仓库, 开发完成后, 需要将代码回传云桌面.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

93 lines
2.3 KiB

  1. const path = require("path")
  2. const HtmlWebpackPlugin = require("html-webpack-plugin")
  3. const ProgressBarPlugin = require("progress-bar-webpack-plugin")
  4. const { CleanWebpackPlugin } = require("clean-webpack-plugin")
  5. const isDevelopment = process.env.NODE_ENV === "development"
  6. // 清理缓存,避免本地缓存越来越大
  7. if (isDevelopment) {
  8. const cachePath = path.resolve(__dirname,"../node_modules/.cache")
  9. new CleanWebpackPlugin().removeFiles([cachePath])
  10. }
  11. const outputPath = (function () {
  12. return path.resolve(__dirname, "../dist")
  13. })()
  14. let commonConfig = {
  15. target: ["web", "es5"],
  16. entry: {
  17. index: path.resolve(__dirname, "../src/index.jsx")
  18. },
  19. output: {
  20. filename: "static/js/[name]_[chunkhash:4].js",
  21. path: outputPath,
  22. clean: true,
  23. },
  24. cache: {
  25. type: "filesystem",
  26. },
  27. resolve: {
  28. alias: {
  29. "@": path.resolve(__dirname, "../src"),
  30. },
  31. extensions: [".jsx", ".js", ".json"],
  32. symlinks: false,
  33. },
  34. module: {
  35. rules: [
  36. {
  37. test: /\.jsx?$/,
  38. use: {
  39. loader: "babel-loader",
  40. },
  41. include: [path.resolve(__dirname, "../src")],
  42. exclude: /node_modules/,
  43. },
  44. {
  45. test: /\.css$/,
  46. include: [
  47. path.resolve(__dirname, "../src"),
  48. path.resolve(__dirname, "../node_modules/leaflet"),
  49. ],
  50. use: ["style-loader", "css-loader", "postcss-loader"],
  51. },
  52. {
  53. test: /\.scss$/,
  54. include: [path.resolve(__dirname, "../src")],
  55. use: ["style-loader", "css-loader", "postcss-loader", "sass-loader"],
  56. },
  57. {
  58. test: /\.(png|jpe?g|gif|bmp|svg)$/,
  59. include: [
  60. path.resolve(__dirname, "../src"),
  61. path.resolve(__dirname, "../node_modules/leaflet"),
  62. ],
  63. type: "asset",
  64. generator: {
  65. filename: "static/images/[name]_[hash].[ext]",
  66. },
  67. },
  68. {
  69. test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
  70. include: [path.resolve(__dirname, "../src")],
  71. type: "asset",
  72. generator: {
  73. filename: "static/fonts/[name]_[hash].[ext]",
  74. },
  75. },
  76. ],
  77. },
  78. plugins: [
  79. new HtmlWebpackPlugin({
  80. template: path.resolve(__dirname, "../public/index.html"),
  81. chunks: ["index"],
  82. baseApi: isDevelopment ? "/PMS" : "/PMS",
  83. }),
  84. new ProgressBarPlugin(),
  85. ],
  86. }
  87. module.exports = commonConfig