next.config.js 694 B

123456789101112131415161718192021222324252627
  1. const webpack = require('webpack');
  2. const withTM = require('next-transpile-modules');
  3. module.exports = withTM({
  4. transpileModules: ['query-string', 'split-on-first', 'strict-uri-encode'],
  5. webpack: (config) => {
  6. const originalEntry = config.entry;
  7. config.entry = async () => {
  8. const entries = await originalEntry();
  9. if (
  10. entries['main.js'] &&
  11. !entries['main.js'].includes('./polyfills.js')
  12. ) {
  13. entries['main.js'].unshift('./polyfills.js')
  14. }
  15. return entries;
  16. };
  17. config.plugins.push(
  18. new webpack.DefinePlugin({
  19. 'process.env.ENV': JSON.stringify(process.env.ENV),
  20. }),
  21. );
  22. return config;
  23. },
  24. });