jaredpalmer / tsdx

Zero-config CLI for TypeScript package development
https://tsdx.io
MIT License
11.22k stars 507 forks source link

@rollup/plugin-image is not working #969

Open chandangowda opened 3 years ago

chandangowda commented 3 years ago

i followed the step to configure images but it is not working by code snippet for rollup images is:

const postcss = require('rollup-plugin-postcss');
const images = require('@rollup/plugin-image');

module.exports = {
  rollup(config) {   
    config.plugins.push(
      postcss({
        plugins: [],
      })
    );
    config.plugins = [
      images(),
      ...config.plugins,
    ]
    return config;
  },
};
chandangowda commented 3 years ago

even tried all the configuration which was mentioned in other issues still not working my image is present inside src folder and even tried to place image in project folder still not working

below is the retired code:

const postcss = require('rollup-plugin-postcss');
const images = require('@rollup/plugin-image');

module.exports = {
  rollup(config) {   
    config.plugins.push(
      postcss({
        plugins: [],
      })
    );
    config.plugins = [
      images({ include: ['**/*.png', '**/*.jpg'] }),
      ...config.plugins,
    ]
    return config;
  },
};
chandangowda commented 3 years ago

Here is my project https://github.com/chandangowda/Tsdx

saadjhk commented 2 years ago

I can confirm this problem exists for svg files as well.

shikelong commented 2 years ago

How to fix it?

saadjhk commented 2 years ago

@shikelong i tried copy roll up plugin, it didn't work for me either

dan-hu-spring commented 2 years ago

Still not working :(

MoltenCoffee commented 1 year ago

This is quite an old issue, but for anyone coming here from a search engine: the solution is to use relative paths. So:

// DO NOT
import img from "images/image.png";

// DO
import img from "./images/image.png";