vue.config.js 2.1 KB

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