vue.config.js 2.0 KB

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