vue.config.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. const { defineConfig } = require("@vue/cli-service");
  2. const linariaLessLoader = require("@queenjs/webpack-loader/linaria-loader");
  3. const modifyVars = require("./src/styles/theme-antd");
  4. const path = require("path");
  5. const publicPath =
  6. process.env.NODE_ENV === "production"
  7. ? `//infishwaibao.oss-cn-chengdu.aliyuncs.com/screenshow/`
  8. : "./";
  9. // const publicPath = "./";
  10. // //
  11. module.exports = defineConfig({
  12. pages: {
  13. index: "src/pages/website/main.ts",
  14. // frame3d: "src/pages/frame3d/main.ts"
  15. },
  16. outputDir: "dist",
  17. publicPath: publicPath,
  18. transpileDependencies: true,
  19. chainWebpack: (config) => {
  20. const tsRule = config.module.rule("ts");
  21. tsRule
  22. .use("moduse-loader")
  23. .loader("moduse/webpack-loader")
  24. .options({
  25. include: [
  26. path.resolve(__dirname, "./src/modules"),
  27. path.resolve(__dirname, "./src/modules-ctx"),
  28. path.resolve(__dirname, "./src/modules-package"),
  29. path.resolve(__dirname, "./node_modules/@queenjs-modules"),
  30. ],
  31. });
  32. const tsxRule = config.module.rule("tsx");
  33. tsxRule.uses.store.delete("thread-loader");
  34. tsxRule
  35. .use("@linaria/webpack-loader")
  36. .loader("@linaria/webpack-loader")
  37. .options({
  38. // 将.css文件更名为.less
  39. extension: ".linaria.less",
  40. preprocessor: linariaLessLoader("@/styles/theme"),
  41. })
  42. .before("ts-loader");
  43. },
  44. css: {
  45. loaderOptions: {
  46. less: {
  47. lessOptions: {
  48. modifyVars,
  49. javascriptEnabled: true,
  50. },
  51. },
  52. },
  53. },
  54. pluginOptions: {
  55. windicss: {
  56. scan: {
  57. dirs: ["node_modules/@queenjs-modules"],
  58. fileExtensions: ["tsx"]
  59. },
  60. preflight: false,
  61. onOptionsResolved: (options) => {
  62. options.scanOptions.extraTransformTargets = {
  63. css: [(f) => {
  64. if (/node_modules\\@queenjs-modules\\.+\.(css|less)/.test(f)) {
  65. return true;
  66. }
  67. return false;
  68. }],
  69. detect: [],
  70. }
  71. return options
  72. },
  73. // see https://github.com/windicss/vite-plugin-windicss/blob/main/packages/plugin-utils/src/options.ts
  74. },
  75. },
  76. });