vue.config.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. const path = require("path");
  2. const HardSourceWebpackPlugin = require("hard-source-webpack-plugin");
  3. const AutoDllPlugin = require("autodll-webpack-plugin");
  4. function resolve(dir) {
  5. return path.join(__dirname, dir);
  6. }
  7. module.exports = {
  8. assetsDir: "h5",
  9. configureWebpack: config => {
  10. Object.assign(config.resolve.alias, {
  11. "@utils": resolve("src/utils"),
  12. "@libs": resolve("src/libs"),
  13. "@api": resolve("src/api"),
  14. "@components": resolve("src/components"),
  15. "@assets": resolve("src/assets"),
  16. "@css": resolve("src/assets/css"),
  17. "@images": resolve("src/assets/images"),
  18. "@views": resolve("src/views"),
  19. "@mixins": resolve("src/mixins")
  20. });
  21. if (process.env.NODE_ENV !== "production") {
  22. config.plugins.push(
  23. new HardSourceWebpackPlugin(),
  24. new AutoDllPlugin({
  25. inject: true,
  26. debug: true,
  27. filename: "[name]_[hash].js",
  28. path: "./dll" + Date.parse(new Date()),
  29. entry: {
  30. vendor_vue: ["vue", "vuex", "vue-router"],
  31. vendor_ui: ["vue-awesome-swiper", "vue-ydui"],
  32. vendor_tools: ["axios", "core-js"]
  33. }
  34. })
  35. );
  36. }
  37. },
  38. chainWebpack: config => {
  39. config.plugin("html").tap(args => {
  40. args[0].VUE_APP_NAME = process.env.VUE_APP_NAME;
  41. return args;
  42. });
  43. }
  44. };