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

Document webpack change: feat: allow to use falsy loaders and plugins #6910

Closed
4 tasks
webpack-bot opened this issue Jun 14, 2023 · 0 comments · Fixed by #6920
Closed
4 tasks

Document webpack change: feat: allow to use falsy loaders and plugins #6910

webpack-bot opened this issue Jun 14, 2023 · 0 comments · Fixed by #6920

Comments

@webpack-bot
Copy link

A pull request by @alexander-akait was merged and maintainers requested a documentation change.

See pull request: webpack/webpack#17339


fixes webpack/webpack#17329
fixes webpack/webpack-cli#3836

Allow to use this, for better DX:

// unknown-loader just for example

//
// For example you can use 
// 
// const needEnablePlugin = process.env.MY_PLUGIN ? true : null;
// `null` can be changed on any `falsy` value, i.e.:
// `false`, `null`, `0`, `""`

module.exports = {
  module: {
    defaultRules: [
      nullValue && {
        test: /\.js$/,
        loader: "unknown-loader",
      },
      "...",
    ],
    rules: [
      nullValue && {
        test: /\.js$/,
        loader: "unknown-loader",
      },
      {
        test: /foo\.js$/,
        oneOf: [
          nullValue && {
            resourceQuery: /inline/,
            loader: "unknown-loader",
          },
          {
            resourceQuery: /external/,
            type: "asset/resource",
          },
        ],
      },
      {
        test: /bar\.js$/,
        use: [nullValue && "unknown-loader"],
      },
      {
        test: /baz\.js$/,
        resourceQuery: /custom-use/,
        use: () => {
          return [
            nullValue && {
              loader: "unknown-loader",
            },
          ];
        },
      },
    ],
  },
  plugins: [
    undefinedValue && new FailPlugin(),
    nullValue && new FailPlugin(),
    falseValue && new FailPlugin(),
    zeroValue && new FailPlugin(),
    emptyStringValue && new FailPlugin(),
  ],
  resolve: {
    plugins: [
      undefinedValue && new FailPlugin(),
    ]
  },
  optimization: {
    minimize: true,
    minimizer: [nullValue && new FailPlugin()],
  },
};

How to merge:

Summary

🤖 Generated by Copilot at b5bb3a1

No summary available (Limit exceeded: required to process 187074 tokens, but only 50000 are allowed per call)

Details

🤖 Generated by Copilot at b5bb3a1

No walkthrough available (Limit exceeded: required to process 187074 tokens, but only 50000 are allowed per call)

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

Successfully merging a pull request may close this issue.

1 participant