vue.config2.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. const modifyVars = require("./src/styles/theme-antd");
  2. const path = require('path');
  3. const fs = require('fs');
  4. const MiniCssExtractPlugin = require('mini-css-extract-plugin');
  5. const getDirectories = (source) =>
  6. fs
  7. .readdirSync(source, { withFileTypes: true })
  8. .filter((dirent) => dirent.isDirectory())
  9. .map((dirent) => dirent.name);
  10. const getAlias = (alias, path) => {
  11. const aliases = {};
  12. const dirs = getDirectories(path);
  13. dirs.forEach((dir) => (aliases[`${alias}/${dir}`] = `${path}/${dir}`));
  14. return aliases;
  15. };
  16. const aliases = getAlias('@', path.resolve(__dirname, './src'));
  17. module.exports = {
  18. publicPath: "./",
  19. // process.env.NODE_ENV === 'production'
  20. // ? `//infishwaibao.oss-cn-chengdu.aliyuncs.com/bess/`
  21. // : './',
  22. lintOnSave: false,
  23. pages: {
  24. index: {
  25. entry: 'src/pages/website/main.ts',
  26. template: 'public/index.html',
  27. filename: 'index.html',
  28. chunks: ['chunk-vendors', 'chunk-common', 'index']
  29. },
  30. frame3d: {
  31. entry: 'src/pages/frame3d/main.ts',
  32. template: 'public/index.html',
  33. filename: 'frame3d.html',
  34. chunks: ['chunk-vendors', 'chunk-common', 'frame3d']
  35. },
  36. },
  37. css: {
  38. loaderOptions: {
  39. less: {
  40. lessOptions: {
  41. modifyVars,
  42. javascriptEnabled: true,
  43. },
  44. },
  45. },
  46. },
  47. chainWebpack: (config) => {
  48. // if (process.env.NODE_ENV === 'production') {
  49. // config.plugin('extract-css').tap((args) => {
  50. // args[0].ignoreOrder = true;
  51. // return args;
  52. // });
  53. // config.optimization.minimizer('terser').tap(args => {
  54. // Object.assign(args[0].terserOptions.compress, {
  55. // pure_funcs: ['console.log']
  56. // })
  57. // return args
  58. // })
  59. // }
  60. const tsRule = config.module.rule("ts");
  61. tsRule
  62. .use("moduse-loader")
  63. .loader("moduse/webpack-loader")
  64. .options({
  65. include: [
  66. path.resolve(__dirname, "./src/modules"),
  67. path.resolve(__dirname, "./node_modules/@queenjs-modules"),
  68. ],
  69. });
  70. },
  71. configureWebpack: {
  72. module: {
  73. rules: [
  74. {
  75. test: /\.(tsx)$/,
  76. use: [
  77. {
  78. loader: '@linaria/webpack-loader',
  79. options: {
  80. sourceMap: process.env.NODE_ENV !== 'production',
  81. babelOptions: {
  82. plugins: [
  83. [
  84. 'babel-plugin-module-resolver',
  85. {
  86. root: ['.'], //the value mentioned in the path section of the `tsconfig.json based on your CWD`
  87. extensions: ['.tsx', '.ts'],
  88. alias: aliases, //The important part!!
  89. },
  90. ],
  91. ],
  92. },
  93. },
  94. },
  95. ],
  96. }, {
  97. test: /\.svga$/,
  98. use: [{ loader: 'file-loader' }],
  99. },
  100. {
  101. test: /\.(frag|vert|glsl)$/,
  102. use: [{ loader: 'raw-loader' }],
  103. }, {
  104. test: /\.(glb)$/,
  105. use: [{ loader: 'url-loader' }],
  106. },
  107. ],
  108. },
  109. },
  110. };