Skip to content

Multiple targets with multiple entries #1150

@alansouzati

Description

@alansouzati

I'm trying to learn Rollup and hopefully use that in a component library I support.

The structure of my project is roughly like this:

  /project
    /src
      /components
        Button.js
        Anchor.js
      index.js

When I prepare my build for production I would like to have the following dist structure:

  /project
    /dist
       /components
          Button.js (csjs target compiled with babel)
          Anchor.js (csjs target compiled with babel)
       library.min.js (iife target to be used in the browser)

Please forgive me if this is a simple question, I'm totally new to rollupjs. What the configuration would look like for this kind of output?

I'm assuming I would have to use multiple entries plugin. But I'm confused how I match that with multiple targets.

import buble from 'rollup-plugin-buble';

export default {
  entry: ['src/index.js', 'src/components/**/*.js'],
  plugins: [ ... ],
  targets: [
    { entry: 'src/index.js', dest: 'dist/library.min.js', format: 'iife', plugins: [minify...] },
    { entry: 'src/components/**/*.js', dest: 'dist/components/', format: 'csjs'},
  ]
};

I'm trying to avoid running babel twice, so I really would like to get this output in one single run.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions