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

[bug] unable to disable extension or set option #2669

Open
3 tasks done
pkosciak opened this issue Dec 15, 2024 · 0 comments
Open
3 tasks done

[bug] unable to disable extension or set option #2669

pkosciak opened this issue Dec 15, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@pkosciak
Copy link

Agreement

Describe the issue

I have a directory inside publicPath that I would like to exclude from cleanup.

This is my public path setting:
app.setPublicPath('/app/themes/sage/public/');

According to bud documentation on extensions, I've tried configuring this in bud.config.js as follows:

app.extensions.get('@roots/bud-extensions/clean-webpack-plugin').set('cleanOnceBeforeBuildPatterns', [`**/*`, `!vendor/**`]);

However, this doesn't work. When I run bud build, the vendor directory inside /public is still removed.

I also tried completely disabling the extension, but that doesn't seem to work either:

app.extensions.get('@roots/bud-extensions/clean-webpack-plugin').disable();

vendor directory isn't part of bud setup, it's just directory that contains livewire esm file published via acorn using command wp acorn vendor:publish --tag=livewire:assets

By the way, I believe there is an error in the documentation: https://bud.js.org/learn/general-use/extensions#enable-a-registered-extension. The correct extension name is clean-webpack-plugin, not webpack-clean-plugin.

Expected Behavior

The yarn build command should preserve the vendor directory inside the public folder as it is excluded in extension options.

Actual Behavior

Setting an option in the extension doesn't seem to work. Additionally, it appears that I cannot disable the extension at all.

Steps To Reproduce

  1. Create vendor directory inside public folder
  2. Add configuration into bud.config.js
  3. Run yarn build

version

6.24.0

Logs

No response

Configuration

/**
 * Compiler configuration
 *
 * @see {@link https://roots.io/sage/docs sage documentation}
 * @see {@link https://bud.js.org/learn/config bud.js configuration guide}
 *
 * @type {import('@roots/bud').Config}
 */
export default async (app) => {
  /**
   * Application assets & entrypoints
   *
   * @see {@link https://bud.js.org/reference/bud.entry}
   * @see {@link https://bud.js.org/reference/bud.assets}
   */
  app
    .entry('app', ['@scripts/app', '@styles/app'])
    .entry('editor', ['@scripts/editor', '@styles/editor'])
    .entry('admin', ['@scripts/admin', '@styles/admin'])
    .assets(['images']);

  /**
   * Set public path
   *
   * @see {@link https://bud.js.org/reference/bud.setPublicPath}
   */
  app.setPublicPath('/app/themes/sage/public/');

  /**
   * Development server settings
   *
   * @see {@link https://bud.js.org/reference/bud.setUrl}
   * @see {@link https://bud.js.org/reference/bud.setProxyUrl}
   * @see {@link https://bud.js.org/reference/bud.watch}
   */
  app
    .setUrl('https://localhost:3000')
    .setProxyUrl('https://website.test')
    .watch(['resources/views', 'app']);

  app.serve({
    ssl: true,
    host: 'website.test',
    cert: app.path('cert.pem'),
    key: app.path('key.pem'),
  });

  /**
   * Generate WordPress `theme.json`
   *
   * @note This overwrites `theme.json` on every build.
   *
   * @see {@link https://bud.js.org/extensions/sage/theme.json}
   * @see {@link https://developer.wordpress.org/block-editor/how-to-guides/themes/theme-json}
   */
  app.wpjson
    .setSettings({
      background: {
        backgroundImage: true,
      },
      color: {
        custom: false,
        customDuotone: false,
        customGradient: false,
        defaultDuotone: false,
        defaultGradients: false,
        defaultPalette: false,
        duotone: [],
      },
      custom: {
        spacing: {},
        typography: {
          'font-size': {},
          'line-height': {},
        },
      },
      spacing: {
        padding: true,
        units: ['px', '%', 'em', 'rem', 'vw', 'vh'],
      },
      typography: {
        customFontSize: false,
      },
    })
    .useTailwindColors()
    .useTailwindFontFamily()
    .useTailwindFontSize();

  // app.extensions.get('@roots/bud-extensions/clean-webpack-plugin').disable();

  app.extensions
    .get('@roots/bud-extensions/clean-webpack-plugin')
    .set('cleanOnceBeforeBuildPatterns', [`**/*`, `!vendor/**`]);
};

Relevant .budfiles

No response

@pkosciak pkosciak added the bug Something isn't working label Dec 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant