vue.config.js 2.0 KB

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