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

feat: enable inline chunks based on conditions through output options #3000

Merged
merged 1 commit into from
Jul 25, 2024

Conversation

Thulof
Copy link
Contributor

@Thulof Thulof commented Jul 23, 2024

Summary

Support inline chunks in development mode

Related Links

#2957

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

@chenjiahan
Copy link
Member

chenjiahan commented Jul 24, 2024

Thanks for your contribution!

I prefer extend the current output.inlineStyles config instead of adding a new dev.inlineStyles config.

We can extend the config type like this:

type InlineStylesTest =
  | RegExp
  | ((params: { size: number; name: string }) => boolean);

type InlineStyles =
  | boolean
  | InlineStylesTest
  | {
      enable?: boolean | 'auto';
      test: InlineStylesTest;
    };

Example:

export default {
  output: {
    inlineStyles: {
      enable: true,
      test: /[\\/]main\.\w+\.css$/,
    },
  },
};

And output.inlineStyles: true is equivalent to enable: 'auto', which means it is only enabled in production build.

export default {
  output: {
    inlineStyles: {
      enable: 'auto',
    },
  },
};

If enable is true, it will works in both dev build and prod build:

export default {
  output: {
    inlineStyles: {
      enable: true,
    },
  },
};

@Thulof Thulof force-pushed the feat/dev-inlineStyles branch from ad7e74e to 7ab2e8b Compare July 24, 2024 18:25
@Thulof Thulof changed the title feat: add dev.inlineStyles config feat: support inline chunks in development mode Jul 24, 2024
@Thulof Thulof force-pushed the feat/dev-inlineStyles branch 2 times, most recently from 7305c7f to 1c1b9b6 Compare July 24, 2024 18:37
@Thulof Thulof force-pushed the feat/dev-inlineStyles branch from 1c1b9b6 to 8261521 Compare July 24, 2024 18:38
@Thulof Thulof changed the title feat: support inline chunks in development mode feat: enable inline chunks based on conditions through output options Jul 24, 2024
Copy link
Member

@chenjiahan chenjiahan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Thanks ❤️

@chenjiahan chenjiahan merged commit ba3693a into web-infra-dev:main Jul 25, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants