vue.config.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. // const path = require("path");
  2. // function resolve(dir) {
  3. // return path.join(__dirname, ".", dir);
  4. // }
  5. // const webpack = require("webpack");
  6. // const IncludeAssetsPlugin = require("html-webpack-include-assets-plugin");
  7. // const CopyWebpackPlugin = require("copy-webpack-plugin");
  8. // const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
  9. // const CompressionWebpackPlugin = require("compression-webpack-plugin");
  10. // const ThemeColorReplacer = require("webpack-theme-color-replacer");
  11. // const { getThemeColors, modifyVars } = require("./src/common/theme/themeUtil");
  12. // const {
  13. // resolveCss
  14. // } = require("./src/common/theme/theme-color-replacer-extend");
  15. // const isProduction = process.env.NODE_ENV === "production";
  16. // let glob = require("glob");
  17. // function getEntry(globPath) {
  18. // let entries = {},
  19. // basename,
  20. // tmp,
  21. // pathname;
  22. // glob.sync(globPath).forEach(function(entry) {
  23. // basename = path.basename(entry, path.extname(entry));
  24. // tmp = entry.split("/").splice(-3);
  25. // pathname = basename; // 正确输出js和html的路径
  26. // var fileIs = glob.sync(entry + tmp[1] + ".html");
  27. // if (tmp[1] === "common") {
  28. // return;
  29. // }
  30. // entries[pathname] = {
  31. // entry: "src/" + tmp[0] + "/" + tmp[1] + "/main.js",
  32. // template: fileIs.length
  33. // ? "src/" + tmp[0] + "/" + tmp[1] + "/" + tmp[1] + ".html"
  34. // : "public/index.html",
  35. // title: "",
  36. // filename: tmp[1] + ".html",
  37. // chunks: ["chunk-vendors", "chunk-common", pathname]
  38. // };
  39. // });
  40. // return entries;
  41. // }
  42. // module.exports = {
  43. // publicPath: process.env.BASE_URL,
  44. // productionSourceMap: false,
  45. // pluginOptions: {
  46. // "style-resources-loader": {
  47. // preProcessor: "less",
  48. // patterns: [path.resolve(__dirname, "./src/assets/styles/theme.less")]
  49. // }
  50. // },
  51. // chainWebpack: config => {
  52. // config.module.rules.delete("svg");
  53. // config.module
  54. // .rule("svg-sprite-loader")
  55. // .test(/\.svg$/)
  56. // .include.add(resolve("src/assets/icons"))
  57. // .end()
  58. // .use("svg-sprite-loader")
  59. // .loader("svg-sprite-loader")
  60. // .options({
  61. // symbolId: "icon-[name]"
  62. // });
  63. // // 生产环境下关闭css压缩的 colormin 项,因为此项优化与主题色替换功能冲突
  64. // if (isProduction) {
  65. // config.plugin("optimize-css").tap(args => {
  66. // args[0].cssnanoOptions.preset[1].colormin = false;
  67. // return args;
  68. // });
  69. // }
  70. // },
  71. // css: {
  72. // // extract: true,
  73. // loaderOptions: {
  74. // less: {
  75. // javascriptEnabled: true,
  76. // modifyVars: modifyVars(),
  77. // lessOptions: {
  78. // modifyVars: modifyVars()
  79. // }
  80. // }
  81. // }
  82. // },
  83. // pages: getEntry("./src/pages/**?/"),
  84. // configureWebpack: config => {
  85. // if (isProduction) {
  86. // config.plugins.push(
  87. // new UglifyJsPlugin({
  88. // uglifyOptions: {
  89. // compress: {
  90. // drop_debugger: true,
  91. // drop_console: true
  92. // }
  93. // },
  94. // sourceMap: false,
  95. // parallel: true
  96. // })
  97. // );
  98. // config.plugins.push(
  99. // new CompressionWebpackPlugin({
  100. // algorithm: "gzip",
  101. // test: new RegExp("\\.(" + ["js", "css"].join("|") + ")$"),
  102. // threshold: 10240,
  103. // minRatio: 0.8
  104. // })
  105. // );
  106. // config.plugins.push(
  107. // new webpack.optimize.LimitChunkCountPlugin({
  108. // maxChunks: 5,
  109. // minChunkSize: 100
  110. // })
  111. // );
  112. // }
  113. // config.plugins.push(
  114. // new ThemeColorReplacer({
  115. // fileName: "css/theme-colors-[contenthash:8].css",
  116. // matchColors: getThemeColors(),
  117. // injectCss: true,
  118. // resolveCss
  119. // })
  120. // );
  121. // return {
  122. // devtool: "cheap-source-map",
  123. // externals: {
  124. // vue: "Vue",
  125. // "vue-router": "VueRouter",
  126. // moment: "moment",
  127. // vuex: "Vuex",
  128. // "ant-design-vue": "antd"
  129. // },
  130. // plugins: [
  131. // new webpack.DllReferencePlugin({
  132. // context: __dirname,
  133. // manifest: path.resolve(__dirname, "dll", "manifest.json")
  134. // }),
  135. // new IncludeAssetsPlugin({
  136. // assets: [
  137. // {
  138. // path: "dll",
  139. // glob: "*.js",
  140. // globPath: path.join(__dirname, "dll")
  141. // }
  142. // ],
  143. // append: false
  144. // }),
  145. // new CopyWebpackPlugin([
  146. // {
  147. // from: path.join(__dirname, "dll"),
  148. // to: path.join(__dirname, "dist", "dll")
  149. // }
  150. // ])
  151. // ]
  152. // };
  153. // }
  154. // };