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

Using rollup with webpack in web app #522

Closed
borisirota opened this issue Feb 18, 2016 · 9 comments · Fixed by #680
Closed

Using rollup with webpack in web app #522

borisirota opened this issue Feb 18, 2016 · 9 comments · Fixed by #680

Comments

@borisirota
Copy link
Contributor

Its more a question than issue.

I would like to use rollup for its tree shaking and minimal bundle size (compare to alternatives) capabilities for JS files in my project as a pre step before running webpack to bundle it with other assets (css, images, etc.).

Currently, rollup is failing because it doesn't understand css syntax.

Is it possible to achieve only js [,jsx] bundling and ignore all other file types (treat it as external) without specifying each file's path in the externals array (which can be very tedious) ? treat it exactly like node_modules without the node-resolve plugin.

Maybe something like webpack's resolve.extensions.

Thanks

@Victorystick
Copy link
Contributor

It may make sense to provide a function to the external option, or to let the external array contain functions. That way, you could do:

export default {
  ...
  external: [
    function ( id ) { return id.endsWith( '.css' ); }
  ]
};

@egoist
Copy link

egoist commented May 26, 2016

Any news on this feature? 🤔

@travi
Copy link

travi commented Jun 5, 2016

I also have this use case, but for .scss files. I like the proposal of providing a function, but also wonder if a glob, like **/*.scss, could be supported. From the config perspective at least, that approach seems a bit simpler.

@Rich-Harris
Copy link
Contributor

A good workaround in the meantime might be to use glob.sync:

// rollup.config.js
import { resolve } from 'path';
import { sync as glob } from 'glob';

export default {
  ...,
  external: glob( '**/*.css' ).map( file => resolve( file ) ).concat( 'otherExternal' )
};

That would automatically exclude all .css files.

I don't think an equivalent to resolve.extensions makes sense, because that feature is designed to allow you to write broken code (by skipping the file extension). Adding built-in glob support would add a lot of complexity for something that's a fairly niche feature.

I do like the idea of allowing external to be a function though.

@travi
Copy link

travi commented Jun 5, 2016

Thanks. That's basically where I landed last night, but I hadn't made it back here yet to include the suggestion.

Rich-Harris added a commit that referenced this issue Jun 5, 2016
allow options.external to be a function
@Rich-Harris
Copy link
Contributor

In 0.26.5 you can supply a function instead of an array for options.external, so I've closed this. Thanks all

@travi
Copy link

travi commented Jun 6, 2016

Very helpful update. Mind including details in the wiki that covers options for external?

@Rich-Harris
Copy link
Contributor

done 👍

@borisirota
Copy link
Contributor Author

Awesome 👍 Thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants