vue.config.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. devServer: {
  18. client: {
  19. overlay: {
  20. errors: true,
  21. warnings: false,
  22. runtimeErrors: false,
  23. },
  24. },
  25. },
  26. chainWebpack: (config) => {
  27. const tsRule = config.module.rule("ts");
  28. tsRule
  29. .use("moduse-loader")
  30. .loader("moduse/webpack-loader")
  31. .options({
  32. include: [
  33. path.resolve(__dirname, "./src/modules"),
  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. },
  82. },
  83. });