-
Notifications
You must be signed in to change notification settings - Fork 507
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
SVG / Image Import #343
Comments
@seanemmer, can you try to extend the config with |
I attempted this but no luck. tsdx.config.js below:
|
I have the same problem, const postcss = require('rollup-plugin-postcss');
const autoprefixer = require('autoprefixer');
const cssnano = require('cssnano');
const image = require('@rollup/plugin-image');
module.exports = {
rollup(config, options) {
config.plugins.push(
image(),
postcss({
plugins: [
autoprefixer(),
cssnano({
preset: 'default',
}),
]
})
);
return config;
},
}; |
I was able to get it working, but I had to specifically include the files in the build output and inline them. const svg = require('rollup-plugin-svg');
module.exports = {
rollup(config) {
const external = config.external;
config.external = id => (id.match(/.svg$/) ? false : external(id));
config.plugins.push(
svg({
base64: false,
})
);
return config;
},
}; |
For me, it had to do with plugin order. Putting const postcss = require('rollup-plugin-postcss');
const autoprefixer = require('autoprefixer');
const cssnano = require('cssnano');
const image = require('@rollup/plugin-image');
module.exports = {
rollup(config, options) {
config.plugins.push(
postcss({
plugins: [
autoprefixer(),
cssnano({
preset: 'default',
}),
],
})
);
config.plugins.unshift(image());
return config;
},
}; |
As @hrgui mentioned, I believe the config order is the key detail here. See also #379 (comment) / #386 (comment) / #278
@chrbala that's a separate issue related to externals or aliases: #91 . See also #379 (comment) |
@chrbala's solution worked for me! I just had to create a declare module "*.svg" {
const content: any;
export default content;
} |
Current Behavior
SVG imports into TS/TSX files are not found
Desired Behavior
The ability to import SVGs into TS/TSX files
Suggested Solution
Implement rollup-plugin-svg
Who does this impact? Who is this for?
All users
Describe alternatives you've considered
I am currently manually including the SVG in my TSX file which is not a sustainable solution
Additional context
Using v. 0.11.0
The text was updated successfully, but these errors were encountered: