vue.config.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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/cloud/v1/`
  8. // : "./";
  9. const publicPath = "./";
  10. module.exports = defineConfig({
  11. pages: {
  12. index: {
  13. entry: "src/pages/match/index.ts",
  14. title: "定制搭配",
  15. },
  16. login: {
  17. entry: "src/pages/login/index.ts",
  18. title: "登录",
  19. },
  20. },
  21. outputDir: "static",
  22. publicPath: publicPath,
  23. transpileDependencies: true,
  24. chainWebpack: (config) => {
  25. const tsRule = config.module.rule("ts");
  26. tsRule
  27. .use("moduse-loader")
  28. .loader("moduse/webpack-loader")
  29. .options({
  30. include: [
  31. path.resolve(__dirname, "./src/modules"),
  32. path.resolve(__dirname, "./src/modules-ctx"),
  33. path.resolve(__dirname, "./src/modules-package"),
  34. path.resolve(__dirname, "./node_modules/@queenjs-modules"),
  35. ],
  36. });
  37. const tsxRule = config.module.rule("tsx");
  38. tsxRule.uses.store.delete("thread-loader");
  39. tsxRule
  40. .use("@linaria/webpack-loader")
  41. .loader("@linaria/webpack-loader")
  42. .options({
  43. // 将.css文件更名为.less
  44. extension: ".linaria.less",
  45. preprocessor: linariaLessLoader("@/styles/theme"),
  46. })
  47. .before("ts-loader");
  48. },
  49. css: {
  50. loaderOptions: {
  51. less: {
  52. lessOptions: {
  53. modifyVars,
  54. javascriptEnabled: true,
  55. },
  56. },
  57. },
  58. },
  59. pluginOptions: {
  60. windicss: {
  61. scan: {
  62. dirs: ["node_modules/@queenjs-modules"],
  63. fileExtensions: ["tsx"],
  64. },
  65. preflight: false,
  66. onOptionsResolved: (options) => {
  67. // make sure file @apply's get transformed
  68. options.scanOptions.extraTransformTargets = {
  69. css: [
  70. (f) => {
  71. if (/node_modules\\@queenjs-modules\\.+\.(css|less)/.test(f)) {
  72. return true;
  73. }
  74. return false;
  75. },
  76. ],
  77. detect: [],
  78. };
  79. return options;
  80. },
  81. // see https://github.com/windicss/vite-plugin-windicss/blob/main/packages/plugin-utils/src/options.ts
  82. },
  83. },
  84. });