index.js 854 B

123456789101112131415161718192021222324252627282930313233343536
  1. exports.clientAddonConfig = function ({ id, port = 8042 }) {
  2. return {
  3. publicPath: process.env.NODE_ENV === 'production'
  4. ? `/_addon/${id}`
  5. : `http://localhost:${port}/`,
  6. configureWebpack: {
  7. output: {
  8. // Important
  9. filename: 'index.js'
  10. }
  11. },
  12. css: {
  13. extract: false
  14. },
  15. chainWebpack: config => {
  16. config.plugins.delete('preload')
  17. config.plugins.delete('prefetch')
  18. config.plugins.delete('html')
  19. config.plugins.delete('optimize-css')
  20. config.optimization.splitChunks(false)
  21. config.module
  22. .rule('gql')
  23. .test(/\.(gql|graphql)$/)
  24. .use('gql-loader')
  25. .loader(require.resolve('graphql-tag/loader'))
  26. .end()
  27. },
  28. devServer: {
  29. headers: {
  30. 'Access-Control-Allow-Origin': '*'
  31. },
  32. port
  33. }
  34. }
  35. }