Skip to content

Allow Vite/Rollup to build output files specified in the input entry points #73

@aaronstezycki

Description

@aaronstezycki

Having migrated recently from the Slinkity plugin to 11ty-vite, Slinkity would adhere to Rollups entry points specified in the Rollup Options within 'input'.

More on what the input array does here... Rollup Config Options

The bundle's entry point(s) (e.g. your main.js or app.js or index.js). If you provide an array of entry points or an object mapping names to entry points, they will be bundled to separate output chunks.

Currently, the 11ty-vite plugin merges all the CSS files used regardless of mapping out entries using the input config, I'm assuming that the HTML files (with the includes to the css files) are used as the main entry points, thus ignoring anything within the Rollup options input array.

My .elevent.js file looks like ...

  config.addPlugin(vite, {
      viteOptions: {
          build: {
              publicDir: 'public',
              clearScreen: false,
              server: {
                  mode: 'development',
                  middlewareMode: true
              },
              rollupOptions: {
                  input: [
                      './src/assets/css/file1.scss',
                      './src/assets/css/file2.scss',
                      './src/assets/css/file3.scss',
                      './src/assets/js/all.js',
                  ],
                  output: {
                  ...
                  }
              },
              manifest: true
          }
      }
  });

and when doing a final build I get the following files in my dist folder. I get just the 1 concatenated file included within a HTML file.

/dist
  | - assets
      | - css
         | - file1.css <<<
      | - js
        | - app.js

Obviously I understand the reasons for this, only shipping what the app/website actually needs is one of vites features. However outputting the chucks as needed allows the chunks to be used independently (say on codepen/stackblitz).

Expected output should be:

/dist
  | - assets
      | - css
         | - file1.css <<<
         | - file2.css <<<
         | - file3.css <<<
      | - js
        | - app.js

Is there a fix for this, or is the approach in my config incorrect?

Thanks in advance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions