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

Could not resolve '../../icons/toast/success.svg' by use @svgr/rollup and rollup-plugin-typescript2 #357

Closed
bdwenxi opened this issue Nov 16, 2019 · 0 comments

Comments

@bdwenxi
Copy link

bdwenxi commented Nov 16, 2019

💬 Could not resolve '../../icons/toast/success.svg' by use @svgr/rollup and rollup-plugin-typescript2

The following is my rollup configuration file

const defaults = {compilerOptions: {module: 'commonjs'}, exclude: ['node_modules', 'dist']};
    const override = {
        compilerOptions: {module: 'es2015'},
        exclude: ['node_modules', 'dist', 'scripts', 'examples', 'gulpfile.ts', 'common']
    };

    let rollupConfigs: RollupOptions = {
        input: utils.pathResolve(`components/${componentName}/index.tsx`),
        output: {
            file: utils.pathResolve(`dist/${componentName}/index.js`),
            format: 'cjs'
        },
        external: [
            'react',
            'react-dom',
            'better-scroll',
            'classnames',
            'rc-animate',
            'shallowequal'
        ],
        plugins: [
            external(),
            svgr(),
            nodeResovle({extensions: ['.js', '.ts', '.tsx', '.svg']}),
            commonjs({
                include: ['node_modules/**'],
                namedExports: {
                    'node_modules/react/index.js': [
                        'Component',
                        'PureComponent',
                        'Fragment',
                        'Children',
                        'createElement',
                        'createRef',
                        'cloneElement'
                    ],
                    'node_modules/react-dom/index.js': ['render', 'createPortal']
                }
            }),
            typescript({
                verbosity: -1,
                tsconfigDefaults: defaults,
                tsconfig: 'tsconfig.json',
                tsconfigOverride: override,
                objectHashIgnoreUnknownHack: true,
                rollupCommonJSResolveHack: true,
                typescript: require('typescript')
            })
        ]
    };

The following is my tsconfig file

{
    "compilerOptions": {
        "baseUrl": "./",
        "target": "es5",
        "module": "commonjs",
        "composite": true,
        "declaration": true,
        "removeComments": true,
        "downlevelIteration": true,
        "noImplicitThis": true,
        "paths": {
            "@baidu/duui/*": ["./components/*/index.tsx"],
            "duui": ["components/index.tsx"]
        },
        "strictNullChecks": true,
        "moduleResolution": "node",
        "esModuleInterop": true,
        "experimentalDecorators": true,
        "jsx": "react",
        "noUnusedParameters": true,
        "noUnusedLocals": true,
        "importHelpers": true,
        "allowSyntheticDefaultImports": true,
        "lib": ["es2015", "es2016", "es2017", "dom"]
    },
    "exclude": ["node_modules", "dist", "scripts"]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant