index.js 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. 'use strict'
  2. // Template version: 1.3.1
  3. // see http://vuejs-templates.github.io/webpack for documentation.
  4. // Node.js 提供的關於路徑的api
  5. const path = require('path')
  6. module.exports = {
  7. dev: {
  8. // Paths
  9. assetsSubDirectory: 'static', // 存取asset的資料夾路徑
  10. assetsPublicPath: '/', // 存取asset的公開路徑
  11. proxyTable: {}, // proxy相關 還不清楚。中间件本质上是在本地开了一个服务器dev-server,所有的请求都通过这里转发出去,即把浏览器的发送请求代理转发到代理服务器上,再由代理服务器发送请求给目标服务器,从而解决跨域问题
  12. // Various Dev Server settings
  13. host: '10.1.1.205', // 會復值給process.env.HOST
  14. port: 443, // 會復值給process.env.PORT, if port is in use, a free one will be determined
  15. autoOpenBrowser: false,
  16. errorOverlay: true,
  17. notifyOnErrors: true,
  18. poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions-
  19. // 使用Eslint Loader?
  20. // If true, 打包的時候程式碼會被lint
  21. // 而且console會顯示警告被lint的地方
  22. useEslint: true,
  23. // If true, lint的錯誤會造成無法打包
  24. // 而且錯誤訊息會顯示在瀏覽器上
  25. showEslintErrorsInOverlay: false,
  26. /**
  27. * Source Maps
  28. */
  29. // Webpack Source Maps 工具模式
  30. // 可餐考 https://webpack.js.org/configuration/devtool/#development
  31. devtool: 'cheap-module-eval-source-map',
  32. // If you have problems debugging vue-files in devtools,
  33. // set this to false - it *may* help
  34. // https://vue-loader.vuejs.org/en/options.html#cachebusting
  35. cacheBusting: true,
  36. cssSourceMap: true
  37. },
  38. build: {
  39. // resolve這個方法會將第一個引數(絕對的源路徑)和後面的引數合成,後面的路徑是相對路徑(相對於前面的源路徑)
  40. // __dirname是node.js提供的變數,理面的值是這個檔案所在的資料夾位置
  41. // index 是index.html所在的位置
  42. index: path.resolve(__dirname, '../dist/index.html'),
  43. // Paths
  44. assetsRoot: path.resolve(__dirname, '../dist'), // 發佈後的asset的root資料夾
  45. assetsSubDirectory: 'static',
  46. assetsPublicPath: '/post/',
  47. /**
  48. * Source Maps
  49. */
  50. // If true, 發佈會含有source map
  51. productionSourceMap: true,
  52. // Webpack Source Maps 工具模式
  53. // 可餐考 https://webpack.js.org/configuration/devtool/#development
  54. devtool: '#source-map',
  55. // Gzip off by default as many popular static hosts such as
  56. // Surge or Netlify already gzip all static assets for you.
  57. // Before setting to `true`, make sure to:
  58. // npm install --save-dev compression-webpack-plugin
  59. // 壓縮發佈的擋案用的 還不清楚
  60. productionGzip: false,
  61. productionGzipExtensions: ['js', 'css'],
  62. // 可以借由下面的指令查看發佈後各個bundle的大小及關係
  63. // `npm run build --report`
  64. bundleAnalyzerReport: process.env.npm_config_report
  65. }
  66. }