index.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // see http://vuejs-templates.github.io/webpack for documentation.
  2. const path = require('path')
  3. let settings = {}
  4. try {
  5. settings = require('./local.json')
  6. if (settings.target && settings.target.endsWith('/')) {
  7. // replacing trailing slash since it can conflict with some apis
  8. // and that's how actual BE reports its url
  9. settings.target = settings.target.replace(/\/$/, '')
  10. }
  11. console.log('Using local dev server settings (/config/local.json):')
  12. console.log(JSON.stringify(settings, null, 2))
  13. } catch (e) {
  14. console.log('Local dev server settings not found (/config/local.json)')
  15. }
  16. const target = settings.target || 'http://localhost:4000/'
  17. module.exports = {
  18. build: {
  19. env: require('./prod.env'),
  20. index: path.resolve(__dirname, '../dist/index.html'),
  21. assetsRoot: path.resolve(__dirname, '../dist'),
  22. assetsSubDirectory: 'static',
  23. assetsPublicPath: '/',
  24. productionSourceMap: true,
  25. // Gzip off by default as many popular static hosts such as
  26. // Surge or Netlify already gzip all static assets for you.
  27. // Before setting to `true`, make sure to:
  28. // npm install --save-dev compression-webpack-plugin
  29. productionGzip: false,
  30. productionGzipExtensions: ['js', 'css']
  31. },
  32. dev: {
  33. env: require('./dev.env'),
  34. port: 8080,
  35. settings,
  36. assetsSubDirectory: 'static',
  37. assetsPublicPath: '/',
  38. proxyTable: {
  39. '/api': {
  40. target,
  41. changeOrigin: true,
  42. cookieDomainRewrite: 'localhost'
  43. },
  44. '/nodeinfo': {
  45. target,
  46. changeOrigin: true,
  47. cookieDomainRewrite: 'localhost'
  48. },
  49. '/socket': {
  50. target,
  51. changeOrigin: true,
  52. cookieDomainRewrite: 'localhost',
  53. ws: true
  54. },
  55. '/oauth/revoke': {
  56. target,
  57. changeOrigin: true,
  58. cookieDomainRewrite: 'localhost'
  59. }
  60. },
  61. // CSS Sourcemaps off by default because relative paths are "buggy"
  62. // with this option, according to the CSS-Loader README
  63. // (https://github.com/webpack/css-loader#sourcemaps)
  64. // In our experience, they generally work as expected,
  65. // just be aware of this issue when enabling this option.
  66. cssSourceMap: false
  67. }
  68. }