Advertisement
Guest User

Untitled

a guest
Mar 15th, 2022
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. /* eslint-disable @typescript-eslint/no-var-requires */
  2. const withPlugins = require('next-compose-plugins');
  3. const withTM = require('next-transpile-modules')(['@guidelines-portal/shared']);
  4.  
  5. const coreComponentsRegex = /node_modules\/@alfalab\/core-components\//;
  6.  
  7. const allowCoreComponentsUse = (oneOf, ctx) => {
  8. // Отключаем error-loader
  9. if (oneOf.use?.loader === 'error-loader' && oneOf.test.toString().includes('.css')) {
  10. oneOf.exclude = coreComponentsRegex;
  11. }
  12.  
  13. // Разрешаем импортировать css из core-components
  14. if (oneOf.test?.toString() === '/(?<!\\.module)\\.css$/') {
  15. if (!ctx.isServer && oneOf.include?.or) {
  16. oneOf.issuer.or[1] = {
  17. or: [oneOf.issuer.or[1].and[0], coreComponentsRegex],
  18. };
  19. }
  20. }
  21. };
  22.  
  23. module.exports = (config = {}) =>
  24. withPlugins([
  25. [
  26. withTM({
  27. webpack: (config, ctx) => {
  28. config.module.rules.forEach((rule) => {
  29. rule.oneOf?.forEach((oneOf) => allowCoreComponentsUse(oneOf, ctx));
  30. });
  31.  
  32. return config;
  33. },
  34. }),
  35. ],
  36. {
  37. reactStrictMode: true,
  38. eslint: {
  39. ignoreDuringBuilds: true,
  40. },
  41. ...config,
  42. },
  43. ]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement