vue.config.js 1003 B

1234567891011121314151617181920212223242526272829303132333435
  1. const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
  2. const TransformPages = require('uni-read-pages')
  3. const {webpack} = new TransformPages()
  4. const envDev = require('./.env.dev');
  5. const envPrd = require('./env.prd');
  6. const env = process.env.NODE_ENV === 'development' ? envDev : envPrd;
  7. Object.keys(env).forEach(key => {
  8. process.env[key] = env[key];
  9. });
  10. const VUE_APP_REMOTE_HOST = process.env.VUE_APP_REMOTE_HOST;
  11. module.exports = {
  12. transpileDependencies: ['uni-simple-router'],
  13. devServer: {
  14. disableHostCheck: true,
  15. proxy: {
  16. '/*': {
  17. target: `http://${VUE_APP_REMOTE_HOST}`,
  18. changeOrigin: true,
  19. },
  20. },
  21. },
  22. configureWebpack: {
  23. plugins: [
  24. new webpack.DefinePlugin({
  25. ROUTES: webpack.DefinePlugin.runtimeValue(() => {
  26. const tfPages = new TransformPages({
  27. includes: ['path', 'name', 'aliasPath', 'meta']
  28. });
  29. return JSON.stringify(tfPages.routes)
  30. }, true )
  31. })
  32. // new BundleAnalyzerPlugin(),
  33. ],
  34. }
  35. };