jaredpalmer / tsdx

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

tsdx-sass -- @rollup/plugin-image doesn't work in tsdx.config.js #628

Closed tsukhu closed 4 years ago

tsukhu commented 4 years ago

MAINTAINER EDIT: tl;dr OP didn't fill out issue template and was apparently using tsdx-sass, which is a pretty outdated fork, and not tsdx. tsdx-sass predates tsdx.config.js (the fork is unnecessary with tsdx.config.js), so it wasn't being "picked up" because wrong package and outdated version.


Hi, First of all congrats making this great tool. It worked perfectly. I am using a Windows 10 laptop and the latest tsdx 0.12.3 based template. I was wanting to add support for image files and created this file (tsdx.config.js) in the root folder

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

module.exports = {
  rollup(config, options) {
    config.plugins.push(images());

    return config;
  },
};

However it does not seem to be getting picked up when I run tsdx build.

Thanks

agilgur5 commented 4 years ago

tsdx.config.js in root dir is definitely picked up, we even recently added multiple tests around it. Should be able to console.log in there too, I've done it while testing.

Your issue is probably that @rollup/plugin-image seems to depend on plugin order, i.e. being one of the first plugins. You can use unshift instead of push or follow the HOWTO on this: https://github.com/jaredpalmer/tsdx/issues/379#issuecomment-568239477

Please search through issues before filing one, there are multiple duplicates for @rollup/plugin-image

tsukhu commented 4 years ago

@agilgur5 I actually looked at all the issues before filing. Also added console logs but nothing appears. In fact even if I used and incorrect syntax in the tsdx.config.js file it did not cause any failure, so I am suspecting that the tsdx.config.js file is not being picked up. I'll again try out today, but if you could point me to a sample tsdx repo with a rollup extension that will be great

agilgur5 commented 4 years ago

Ok. Those issues do point to plugin order mattering, but you didn't configure like those issues. If your tsdx.config.js isn't being executed then maybe it's in the wrong place.

I linked to two PRs that have passing tests with tsdx.config.js above. You can view the files of one of the integration tests here.

Other than passing end-to-end and integration tests on a CI matrix for Ubuntu, macOS, and Windows on multiple Node versions, there are also many users of tsdx.config.js, and most of the HOWTOs are around it, so it definitely works.

I don't know why yours doesn't work and you also didn't provide a reproduction, so I can't really help you out. You'll need to provide a minimal repro and I think creating one would help you figure out what's going on too.

tsukhu commented 4 years ago

@agilgur5 Thank you so much for your response. I'll get back to you after trying out these

tsukhu commented 4 years ago

@agilgur5 found the issue .. My bad I used tsdx-sass for sass support (instead of adding a rollup config extension) .. This is based on an old version of tsdx and used overriding the tsdx functionality and hence the tsdx.config.js is not being picked up .. Thanks a lot