vue.config.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. const path = require('path');
  2. const fs = require('fs');
  3. const UploadPlugin = require('./upload');
  4. let publicPath;
  5. switch (process.env.NODE_ENV) {
  6. case 'development':
  7. publicPath = '/';
  8. break;
  9. case 'production':
  10. publicPath = `https://cdn.raex.vip/www/` + new Date().getTime();
  11. break;
  12. case 'test':
  13. publicPath = `https://cdn.raex.vip/www_test/` + new Date().getTime();
  14. break;
  15. }
  16. module.exports = {
  17. publicPath: publicPath,
  18. devServer: {
  19. port: 8082,
  20. disableHostCheck: true
  21. },
  22. pluginOptions: {
  23. 'style-resources-loader': {
  24. preProcessor: 'less',
  25. patterns: [path.resolve(__dirname, './src/styles/common/', '*.less')]
  26. }
  27. },
  28. chainWebpack: config => {
  29. if (process.env.NODE_ENV === 'production') {
  30. config.plugin('upload').use(new UploadPlugin(publicPath.replace('https://cdn.raex.vip/', '')));
  31. }
  32. config.output.filename('[name].[hash].js').end();
  33. config.resolve.alias.set('@assets', path.resolve(__dirname, 'src', 'assets'));
  34. config.plugin('html').tap(args => {
  35. args[0].title = process.env.TITLE;
  36. args[0].app = process.env.VUE_APP_CORDOVA === 'true';
  37. return args;
  38. });
  39. },
  40. transpileDependencies: ['element-ui', 'swiper', 'ssr-window', 'dom7', 'vue-awesome-swiper', 'vuex'],
  41. runtimeCompiler: true,
  42. productionSourceMap: false
  43. };