Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* eslint-disable @typescript-eslint/no-var-requires */
- const withPlugins = require('next-compose-plugins');
- const withTM = require('next-transpile-modules')(['@guidelines-portal/shared']);
- const coreComponentsRegex = /node_modules\/@alfalab\/core-components\//;
- const allowCoreComponentsUse = (oneOf, ctx) => {
- // Отключаем error-loader
- if (oneOf.use?.loader === 'error-loader' && oneOf.test.toString().includes('.css')) {
- oneOf.exclude = coreComponentsRegex;
- }
- // Разрешаем импортировать css из core-components
- if (oneOf.test?.toString() === '/(?<!\\.module)\\.css$/') {
- if (!ctx.isServer && oneOf.include?.or) {
- oneOf.issuer.or[1] = {
- or: [oneOf.issuer.or[1].and[0], coreComponentsRegex],
- };
- }
- }
- };
- module.exports = (config = {}) =>
- withPlugins([
- [
- withTM({
- webpack: (config, ctx) => {
- config.module.rules.forEach((rule) => {
- rule.oneOf?.forEach((oneOf) => allowCoreComponentsUse(oneOf, ctx));
- });
- return config;
- },
- }),
- ],
- {
- reactStrictMode: true,
- eslint: {
- ignoreDuringBuilds: true,
- },
- ...config,
- },
- ]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement