Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thank you for this workaround... SVG issue. #12

Open
gfmjr opened this issue Dec 23, 2021 · 4 comments
Open

Thank you for this workaround... SVG issue. #12

gfmjr opened this issue Dec 23, 2021 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@gfmjr
Copy link

gfmjr commented Dec 23, 2021

I currently have a project that has globalCSS in npm components and this workaround is what I'm attempting to use.

Unfortunately, I also use the next-images package for important images of all file types (including SVGs).

No matter what, running next-global-css attempts to also parse SVG files and always errors with:
error - SyntaxError: Unexpected token '<'

Is there a way to exclude SVG files easily from next-global-css, or make it skip them entirely by default?

@yarastqt
Copy link
Member

Hi @gfmjr, you can create repo or gist with reproduce this issue?

@yarastqt yarastqt added the bug Something isn't working label Dec 24, 2021
@asader
Copy link

asader commented Feb 16, 2022

Here's what helped me

yarn add @svgr/webpack

next.config.js

const { patchWebpackConfig } = require('next-global-css')

module.exports = {
    webpack: (config, options) => {
        patchWebpackConfig(config, options);
        config.module.rules.push({
            include: /node_modules[\\/]@s7[\\/]ui-kit/,
            test: /\.svg$/,
            use: ['@svgr/webpack'],
        });
        return config;
    }
}

@yarastqt
Copy link
Member

yarastqt commented Apr 6, 2022

Hi @gfmjr, can you check this #12 solution work for you?

@yarastqt yarastqt self-assigned this Apr 6, 2022
@gfmjr
Copy link
Author

gfmjr commented Apr 7, 2022

It's not the best solution, but it works. We managed to resolved it in this fashion with a different package.... I probably could have made your solution work as well but we had other repos using this already so stuck with what our team already knew.

const withImages = require("next-images");
const withTM = require("next-transpile-modules")(['@design/system']);

const baseConfig = withImages({
       ... ,
        webpack(config) {
            return config;
        }
    });

module.exports = withTM({
    ...baseConfig,
 }
);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants