停车场项目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.

86 lines
2.1 KiB

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