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] Multiple compilers not compiling tailwindcss #1702

Closed
3 tasks done
Twansparant opened this issue Sep 23, 2022 · 13 comments
Closed
3 tasks done

[bug] Multiple compilers not compiling tailwindcss #1702

Twansparant opened this issue Sep 23, 2022 · 13 comments

Comments

@Twansparant
Copy link
Sponsor

Twansparant commented Sep 23, 2022

Agreement

Describe the issue

Hi there,

I'm following this guide to setup 2 bud child instances, one for my frontend entrypoints and one for my (gutenberg) editor entrypoints:

export default async bud => {
	/**
	 * Frontend css/js
	 *
	 * @param {bud} app
	 */
	await bud.make('app', async app =>
		app
			.setPath('@dist', 'public/app')
			.entry({
				app: ['@scripts/app', '@styles/app'],
				admin: ['@styles/admin'],
				login: ['@styles/login']
			})
			.assets(['images'])
			.provide({
				jquery: ['jQuery', '$']
			})
			.watch(['resources/views/**/*', 'app/**/*'])
			.proxy('https://sage.test')
			.serve('http://0.0.0.0:3000')
			.setPublicPath('/app/themes/sage/public/app/')
	)

	/**
	 * Editor css/js
	 *
	 * @param {bud} editor
	 */
	await bud.make('editor', async editor =>
		editor
			.setPath('@dist', 'public/editor')
			.entry({
				editor: ['@scripts/editor', '@styles/editor']
			})
			.postcss.setPlugin('postcss-editor-styles', [
				bud.module.resolve('postcss-editor-styles'), {
					scopeTo: '.editor-styles-wrapper :not(.acf-block-fields *)',
					tagSuffix: ':not([class^="components-"]):not([class^="editor-"]):not([class^="block-"]):not([aria-owns]):not([class^="acf-"]):not([id^="acf-"])'
				}
			])
	)
}

I have installed the following dev dependencies:

"@roots/bud": "6.4.1",
"@roots/bud-eslint": "6.4.1",
"@roots/bud-preset-wordpress": "6.4.1",
"@roots/bud-prettier": "6.4.1",
"@roots/bud-stylelint": "6.4.1",
"@roots/bud-tailwindcss": "6.4.1",
"@roots/eslint-config": "6.4.1",
"@roots/sage": "6.4.1",
"postcss-editor-styles": "^0.3.0"

In the editor instance I want to use the postcss-editor-styles PostCSS plugin.
Running bud build goes fine, all the assets are nicely in separate folders and the stylesheets are generated, but my compiled app.css starts with:

@layer components

So Tailwindcss is not being processed by PostCSS at all.
Even when I specifically add it to the instance, it won't compile:

app.postcss.setPlugins({
  ['tailwindcss']: await bud.module.resolve('tailwindcss'),
  ['nesting']: await bud.module.resolve('tailwindcss/nesting/index.js'),
})

However if I move the instance outside the bud.make and in the root of the config:

export default async bud => {
	.setPath('@dist', 'public/app')
	.entry({
		app: ['@scripts/app', '@styles/app'],
		admin: ['@styles/admin'],
		login: ['@styles/login']
	})
	.assets(['images'])
	.provide({
		jquery: ['jQuery', '$']
	})
	.watch(['resources/views/**/*', 'app/**/*'])
	.proxy('https://tmnl.test')
	.serve('http://0.0.0.0:3000')
	.setPublicPath('/app/themes/sage/public/app/');
}

It does compile TailwindCSS correctly?
I'm currently not using a postcss.config.js file, but why is it not applying the postcss config to the child instances?
Am I missing something here?

Expected Behavior

Tailwind CSS gets compiled correctly in each bud child instance.

Actual Behavior

Tailwind CSS does not get compiled at all in each bud child instance.

Steps To Reproduce

  1. Setup a project following this bud config:
  2. Install @roots/bud-tailwindcss as devDependency:
yarn add -D @roots/bud-tailwindcss
  1. Import tailwind directives in your entry css:
@tailwind base;
@tailwind components;
@tailwind utilities;
  1. Run bud build
  2. Check your compiled .css files in the public folder.

version

6.4.1

What package manager are you using?

yarn

version

1.22.19

Logs

yarn run v1.22.19
$ npm run clean && bud build --log

[bud@6.4.1] [sage] › ✔  success   logger ready
[bud@6.4.1] [sage] › ✔  success   imported env
[bud@6.4.1] [sage] › ✔  success   imported project
[bud@6.4.1] [sage] › ✔  success   imported compiler
[bud@6.4.1] [sage] › ✔  success   imported dashboard
[bud@6.4.1] [sage] › ✔  success   imported extensions
[bud@6.4.1] [sage] › ✔  success   imported build
[bud@6.4.1] [sage] › ✔  success   imported hooks
[bud@6.4.1] [sage] › ✔  success   imported cache
[bud@6.4.1] [sage] › ✔  success   imported api
[bud@6.4.1] [sage] [bootstrap] › ✔  success   registered service callback: env.bootstrap
[bud@6.4.1] [sage] [bootstrap] › ✔  success   registered service callback: api.bootstrap
[bud@6.4.1] [sage] [bootstrap] › ✔  success   registered service callback: build.register
[bud@6.4.1] [sage] [bootstrap] › ✔  success   registered service callback: api.registered
[bud@6.4.1] [sage] [bootstrap] › ✔  success   registered service callback: extensions.booted
[bud@6.4.1] [sage] [bootstrap] › ✔  success   registered service callback: cache.booted
[bud@6.4.1] [sage] [bootstrap] › ✔  success   registered service callback: extensions.configAfter
[bud@6.4.1] [sage] [bootstrap] › ✔  success   registered service callback: extensions.buildBefore
[bud@6.4.1] [sage] [bootstrap] › ✔  success   registered service callback: project.buildAfter
[bud@6.4.1] [sage] [bootstrap] › ✔  success   registered service callback: extensions.buildAfter
[bud@6.4.1] [sage] [bootstrap] › ✔  success   init
[bud@6.4.1] [sage] [bootstrap] › ✔  success   bootstrap
[bud@6.4.1] [sage] [bootstrap] › ✔  success   bootstrapped
[bud@6.4.1] [sage] [bootstrap] › ✔  success   register
[bud@6.4.1] [sage] [bootstrap] › ✔  success   registered
[bud@6.4.1] [sage] [bootstrap] › ✔  success   boot
[bud@6.4.1] [sage] [module] › ✔  success   imported @roots/bud/extensions/bud-cdn from /path/to/my/theme/sage/node_modules/@roots/bud/lib/extensions/bud-cdn/index.js
[bud@6.4.1] [sage] [extensions] › ✔  success   cdn imported and instantiated
[bud@6.4.1] [sage] [module] › ✔  success   imported @roots/bud/extensions/bud-esm from /path/to/my/theme/sage/node_modules/@roots/bud/lib/extensions/bud-esm/index.js
[bud@6.4.1] [sage] [extensions] › ✔  success   esm imported and instantiated
[bud@6.4.1] [sage] [module] › ✔  success   imported @roots/bud-terser/extension from /path/to/my/theme/sage/node_modules/@roots/bud-terser/lib/extension.js
[bud@6.4.1] [sage] [module] › ✔  success   imported @roots/bud/extensions/clean-webpack-plugin from /path/to/my/theme/sage/node_modules/@roots/bud/lib/extensions/clean-webpack-plugin/index.js
[bud@6.4.1] [sage] [extensions] › ✔  success   clean-webpack-plugin imported and instantiated
[bud@6.4.1] [sage] [module] › ✔  success   imported @roots/bud/extensions/webpack-provide-plugin from /path/to/my/theme/sage/node_modules/@roots/bud/lib/extensions/webpack-provide-plugin/index.js
[bud@6.4.1] [sage] [extensions] › ✔  success   webpack:provide-plugin imported and instantiated
[bud@6.4.1] [sage] [module] › ✔  success   imported @roots/bud/extensions/webpack-define-plugin from /path/to/my/theme/sage/node_modules/@roots/bud/lib/extensions/webpack-define-plugin/index.js
[bud@6.4.1] [sage] [extensions] › ✔  success   webpack:define-plugin imported and instantiated
[bud@6.4.1] [sage] [module] › ✔  success   imported @roots/bud/extensions/webpack-manifest-plugin from /path/to/my/theme/sage/node_modules/@roots/bud/lib/extensions/webpack-manifest-plugin/index.js
[bud@6.4.1] [sage] [extensions] › ✔  success   webpack-manifest-plugin imported and instantiated
[bud@6.4.1] [sage] [module] › ✔  success   imported @roots/bud/extensions/mini-css-extract-plugin from /path/to/my/theme/sage/node_modules/@roots/bud/lib/extensions/mini-css-extract-plugin/index.js
[bud@6.4.1] [sage] [extensions] › ✔  success   mini-css-extract-plugin imported and instantiated
[bud@6.4.1] [sage] [module] › ✔  success   imported @roots/bud/extensions/copy-webpack-plugin from /path/to/my/theme/sage/node_modules/@roots/bud/lib/extensions/copy-webpack-plugin/index.js
[bud@6.4.1] [sage] [extensions] › ✔  success   copy-webpack-plugin imported and instantiated
[bud@6.4.1] [sage] [module] › ✔  success   imported @roots/bud-prettier from /path/to/my/theme/sage/node_modules/@roots/bud-prettier/lib/index.js
[bud@6.4.1] [sage] [extensions] › ✔  success   @roots/bud-prettier imported and instantiated
[bud@6.4.1] [sage] [module] › ✔  success   imported @roots/bud/extensions/webpack-hot-module-replacement-plugin from /path/to/my/theme/sage/node_modules/@roots/bud/lib/extensions/webpack-hot-module-replacement-plugin/index.js
[bud@6.4.1] [sage] [extensions] › ✔  success   webpack:hot-module-replacement-plugin imported and instantiated
[bud@6.4.1] [sage] [module] › ✔  success   imported @roots/bud/extensions/bud-fix-style-only-entrypoints from /path/to/my/theme/sage/node_modules/@roots/bud/lib/extensions/bud-fix-style-only-entrypoints/index.js
[bud@6.4.1] [sage] [extensions] › ✔  success   fix-style-only-entrypoints imported and instantiated
[bud@6.4.1] [sage] [module] › ✔  success   imported @roots/bud-preset-wordpress from /path/to/my/theme/sage/node_modules/@roots/bud-preset-wordpress/lib/index.js
[bud@6.4.1] [sage] [module] › ✔  success   imported @roots/bud-eslint from /path/to/my/theme/sage/node_modules/@roots/bud-eslint/lib/index.js
[bud@6.4.1] [sage] [extensions] › ✔  success   @roots/bud-eslint imported and instantiated
[bud@6.4.1] [sage] [module] › ✔  success   imported @roots/bud-stylelint from /path/to/my/theme/sage/node_modules/@roots/bud-stylelint/lib/index.js
[bud@6.4.1] [sage] [extensions] › ✔  success   @roots/bud-stylelint imported and instantiated
[bud@6.4.1] [sage] [module] › ✔  success   imported @roots/bud-terser/css-minimizer from /path/to/my/theme/sage/node_modules/@roots/bud-terser/lib/css-minimizer/extension.js
[bud@6.4.1] [sage] [extensions] › ✔  success   @roots/bud-terser/css-minimizer imported and instantiated
[bud@6.4.1] [sage] [extensions] › ✔  success   @roots/bud-terser imported and instantiated
[bud@6.4.1] [sage] [module] › ✔  success   imported @roots/bud-tailwindcss from /path/to/my/theme/sage/node_modules/@roots/bud-tailwindcss/lib/index.js
[bud@6.4.1] [sage] [module] › ✔  success   imported @roots/sage from /path/to/my/theme/sage/node_modules/@roots/sage/lib/index.js
[bud@6.4.1] [sage] [module] › ✔  success   imported @roots/bud-preset-recommend from /path/to/my/theme/sage/node_modules/@roots/bud-preset-recommend/lib/index.js
[bud@6.4.1] [sage] [module] › ✔  success   imported @roots/bud-postcss from /path/to/my/theme/sage/node_modules/@roots/bud-postcss/lib/index.js
[bud@6.4.1] [sage] [extensions] › ✔  success   @roots/bud-postcss imported and instantiated
[bud@6.4.1] [sage] [extensions] › ✔  success   @roots/bud-tailwindcss imported and instantiated
[bud@6.4.1] [sage] [module] › ✔  success   imported @roots/sage/acorn from /path/to/my/theme/sage/node_modules/@roots/sage/lib/acorn/extension.js
[bud@6.4.1] [sage] [extensions] › ✔  success   @roots/sage/acorn imported and instantiated
[bud@6.4.1] [sage] [module] › ✔  success   imported @roots/sage/wp-theme-json from /path/to/my/theme/sage/node_modules/@roots/sage/lib/wp-theme-json/extension.js
[bud@6.4.1] [sage] [extensions] › ✔  success   @roots/sage/wp-theme-json imported and instantiated
[bud@6.4.1] [sage] [module] › ✔  success   imported @roots/bud-entrypoints from /path/to/my/theme/sage/node_modules/@roots/bud-entrypoints/lib/index.js
[bud@6.4.1] [sage] [extensions] › ✔  success   @roots/bud-entrypoints imported and instantiated
[bud@6.4.1] [sage] [extensions] › ✔  success   @roots/bud-entrypoints imported and instantiated
[bud@6.4.1] [sage] [extensions] › ✔  success   @roots/bud-preset-recommend imported and instantiated
[bud@6.4.1] [sage] [extensions] › ✔  success   @roots/bud-preset-recommend imported and instantiated
[bud@6.4.1] [sage] [module] › ✔  success   imported @roots/bud-wordpress-externals from /path/to/my/theme/sage/node_modules/@roots/bud-wordpress-externals/lib/index.js
[bud@6.4.1] [sage] [extensions] › ✔  success   @roots/bud-wordpress-externals imported and instantiated
[bud@6.4.1] [sage] [extensions] › ✔  success   @roots/bud-wordpress-externals imported and instantiated
[bud@6.4.1] [sage] [module] › ✔  success   imported @roots/bud-wordpress-dependencies from /path/to/my/theme/sage/node_modules/@roots/bud-wordpress-dependencies/lib/index.js
[bud@6.4.1] [sage] [extensions] › ✔  success   @roots/bud-wordpress-dependencies imported and instantiated
[bud@6.4.1] [sage] [extensions] › ✔  success   @roots/bud-wordpress-dependencies imported and instantiated
[bud@6.4.1] [sage] [module] › ✔  success   imported @roots/bud-wordpress-manifests from /path/to/my/theme/sage/node_modules/@roots/bud-wordpress-manifests/lib/index.js
[bud@6.4.1] [sage] [extensions] › ✔  success   @roots/bud-wordpress-manifests imported and instantiated
[bud@6.4.1] [sage] [extensions] › ✔  success   @roots/bud-wordpress-manifests imported and instantiated
[bud@6.4.1] [sage] [module] › ✔  success   imported @roots/bud-react from /path/to/my/theme/sage/node_modules/@roots/bud-react/lib/index.js
[bud@6.4.1] [sage] [module] › ✔  success   imported @roots/bud-react/react-refresh from /path/to/my/theme/sage/node_modules/@roots/bud-react/lib/react-refresh/index.js
[bud@6.4.1] [sage] [extensions] › ✔  success   @roots/bud-react/react-refresh imported and instantiated
[bud@6.4.1] [sage] [extensions] › ✔  success   @roots/bud-react/react-refresh imported and instantiated
[bud@6.4.1] [sage] [extensions] › ✔  success   @roots/bud-react imported and instantiated
[bud@6.4.1] [sage] [extensions] › ✔  success   @roots/bud-react imported and instantiated
[bud@6.4.1] [sage] [extensions] › ✔  success   @roots/bud-preset-wordpress imported and instantiated
[bud@6.4.1] [sage] [extensions] › ✔  success   @roots/bud-preset-wordpress imported and instantiated
[bud@6.4.1] [sage] [extensions] › ✔  success   @roots/sage imported and instantiated
[bud@6.4.1] [sage] [webpack:define-plugin] › log       initialized
[bud@6.4.1] [sage] [@roots/sage/wp-theme-json] › log       initialized
[bud@6.4.1] [sage] [@roots/bud-eslint] › log       registered
[bud@6.4.1] [sage] [@roots/bud-terser] › log       registered
[bud@6.4.1] [sage] [@roots/bud-postcss] › log       registered
[bud@6.4.1] [sage] [@roots/sage/acorn] › log       registered
[bud@6.4.1] [sage] [@roots/sage/acorn] › ✔  success   set svg generator path
[bud@6.4.1] [sage] [@roots/bud-preset-recommend] › log       registered
[bud@6.4.1] [sage] [@roots/bud-preset-recommend] › ✔  success   imported @roots/bud-babel
[bud@6.4.1] [sage] [@roots/bud-babel] › log       initialized
[bud@6.4.1] [sage] [@roots/bud-babel] › log       registered
[bud@6.4.1] [sage] [@roots/bud-preset-wordpress] › log       registered
[bud@6.4.1] [sage] [@roots/sage] › log       registered
[bud@6.4.1] [sage] › log       alias [{"@fonts":"./resources/fonts","@images":"./resources/images","@scripts":"./resources/scripts","@styles":"./resources/styles"}]
[bud@6.4.1] [sage] › log       minimize (no arguments passed)
[bud@6.4.1] [sage] › log       hash (no arguments passed)
[bud@6.4.1] [sage] › ✔  success   {"message":"file hashing enabled"}
[bud@6.4.1] [sage] › log       runtime ["single"]
[bud@6.4.1] [sage] › log       splitChunks (no arguments passed)
[bud@6.4.1] [sage] [@roots/bud-preset-wordpress] › log       booted
[bud@6.4.1] [sage] [@roots/bud-preset-wordpress] › ✔  success   imported @roots/bud-react
[bud@6.4.1] [sage] › log       proxy ["https://tmnl.test/"]
[bud@6.4.1] [sage] [@roots/bud-cache/invalidate-cache] › log       registered
[bud@6.4.1] [sage] › ✔  success   cache initialized
[bud@6.4.1] [sage] [bootstrap] › ✔  success   booted
[bud@6.4.1] [sage] › log       processing configuration bud.config.mjs
[bud@6.4.1] [sage] › log       instantiating bud {...}
[bud@6.4.1] [app] › ✔  success   logger ready
[bud@6.4.1] [app] › ✔  success   imported env
[bud@6.4.1] [app] › ✔  success   imported hooks
[bud@6.4.1] [app] › ✔  success   imported api
[bud@6.4.1] [app] › ✔  success   imported build
[bud@6.4.1] [app] › ✔  success   imported cache
[bud@6.4.1] [app] › ✔  success   imported extensions
[bud@6.4.1] [app] › ✔  success   imported project
[bud@6.4.1] [app] [bootstrap] › ✔  success   registered service callback: env.bootstrap
[bud@6.4.1] [app] [bootstrap] › ✔  success   registered service callback: api.bootstrap
[bud@6.4.1] [app] [bootstrap] › ✔  success   registered service callback: build.register
[bud@6.4.1] [app] [bootstrap] › ✔  success   registered service callback: api.registered
[bud@6.4.1] [app] [bootstrap] › ✔  success   registered service callback: cache.booted
[bud@6.4.1] [app] [bootstrap] › ✔  success   registered service callback: extensions.booted
[bud@6.4.1] [app] [bootstrap] › ✔  success   registered service callback: extensions.configAfter
[bud@6.4.1] [app] [bootstrap] › ✔  success   registered service callback: extensions.buildBefore
[bud@6.4.1] [app] [bootstrap] › ✔  success   registered service callback: extensions.buildAfter
[bud@6.4.1] [app] [bootstrap] › ✔  success   registered service callback: project.buildAfter
[bud@6.4.1] [app] [bootstrap] › ✔  success   init
[bud@6.4.1] [app] [bootstrap] › ✔  success   bootstrap
[bud@6.4.1] [app] [bootstrap] › ✔  success   bootstrapped
[bud@6.4.1] [app] [bootstrap] › ✔  success   register
[bud@6.4.1] [app] [bootstrap] › ✔  success   registered
[bud@6.4.1] [app] [bootstrap] › ✔  success   boot
[bud@6.4.1] [app] [@roots/bud-cache/invalidate-cache] › log       registered
[bud@6.4.1] [app] › ✔  success   cache initialized
[bud@6.4.1] [app] [extensions] › ✔  success   cdn imported and instantiated
[bud@6.4.1] [app] [extensions] › ✔  success   esm imported and instantiated
[bud@6.4.1] [app] [extensions] › ✔  success   fix-style-only-entrypoints imported and instantiated
[bud@6.4.1] [app] [extensions] › ✔  success   clean-webpack-plugin imported and instantiated
[bud@6.4.1] [app] [extensions] › ✔  success   webpack:provide-plugin imported and instantiated
[bud@6.4.1] [app] [extensions] › ✔  success   webpack-manifest-plugin imported and instantiated
[bud@6.4.1] [app] [extensions] › ✔  success   webpack:hot-module-replacement-plugin imported and instantiated
[bud@6.4.1] [app] [extensions] › ✔  success   webpack:define-plugin imported and instantiated
[bud@6.4.1] [app] [extensions] › ✔  success   mini-css-extract-plugin imported and instantiated
[bud@6.4.1] [app] [extensions] › ✔  success   copy-webpack-plugin imported and instantiated
[bud@6.4.1] [app] [extensions] › ✔  success   @roots/bud-eslint imported and instantiated
[bud@6.4.1] [app] [extensions] › ✔  success   @roots/bud-prettier imported and instantiated
[bud@6.4.1] [app] [extensions] › ✔  success   @roots/bud-stylelint imported and instantiated
[bud@6.4.1] [app] [extensions] › ✔  success   @roots/bud-terser/css-minimizer imported and instantiated
[bud@6.4.1] [app] [extensions] › ✔  success   @roots/bud-postcss imported and instantiated
[bud@6.4.1] [app] [extensions] › ✔  success   @roots/sage/acorn imported and instantiated
[bud@6.4.1] [app] [extensions] › ✔  success   @roots/bud-entrypoints imported and instantiated
[bud@6.4.1] [app] [extensions] › ✔  success   @roots/bud-tailwindcss imported and instantiated
[bud@6.4.1] [app] [extensions] › ✔  success   @roots/sage/wp-theme-json imported and instantiated
[bud@6.4.1] [app] [extensions] › ✔  success   @roots/bud-terser imported and instantiated
[bud@6.4.1] [app] [extensions] › ✔  success   @roots/bud-preset-recommend imported and instantiated
[bud@6.4.1] [app] [extensions] › ✔  success   @roots/bud-wordpress-externals imported and instantiated
[bud@6.4.1] [app] [extensions] › ✔  success   @roots/bud-wordpress-dependencies imported and instantiated
[bud@6.4.1] [app] [extensions] › ✔  success   @roots/bud-preset-recommend imported and instantiated
[bud@6.4.1] [app] [extensions] › ✔  success   @roots/bud-wordpress-manifests imported and instantiated
[bud@6.4.1] [app] [extensions] › ✔  success   @roots/bud-react/react-refresh imported and instantiated
[bud@6.4.1] [app] [extensions] › ✔  success   @roots/bud-react/react-refresh imported and instantiated
[bud@6.4.1] [app] [extensions] › ✔  success   @roots/bud-react imported and instantiated
[bud@6.4.1] [app] [extensions] › ✔  success   @roots/bud-react imported and instantiated
[bud@6.4.1] [app] [extensions] › ✔  success   @roots/bud-preset-wordpress imported and instantiated
[bud@6.4.1] [app] [extensions] › ✔  success   @roots/bud-preset-wordpress imported and instantiated
[bud@6.4.1] [app] [extensions] › ✔  success   @roots/sage imported and instantiated
[bud@6.4.1] [app] [webpack:define-plugin] › log       initialized
[bud@6.4.1] [app] [@roots/sage/wp-theme-json] › log       initialized
[bud@6.4.1] [app] [@roots/bud-eslint] › log       registered
[bud@6.4.1] [app] [@roots/bud-postcss] › log       registered
[bud@6.4.1] [app] [@roots/sage/acorn] › log       registered
[bud@6.4.1] [app] [@roots/sage/acorn] › ✔  success   set svg generator path
[bud@6.4.1] [app] [@roots/bud-terser] › log       registered
[bud@6.4.1] [app] [@roots/bud-preset-recommend] › log       registered
[bud@6.4.1] [app] [@roots/bud-preset-recommend] › ✔  success   imported @roots/bud-babel
[bud@6.4.1] [app] [@roots/bud-babel] › log       initialized
[bud@6.4.1] [app] [@roots/bud-babel] › log       registered
[bud@6.4.1] [app] [@roots/bud-preset-wordpress] › log       registered
[bud@6.4.1] [app] [@roots/sage] › log       registered
[bud@6.4.1] [app] › log       alias [{"@fonts":"./resources/fonts","@images":"./resources/images","@scripts":"./resources/scripts","@styles":"./resources/styles"}]
[bud@6.4.1] [app] › log       minimize (no arguments passed)
[bud@6.4.1] [app] › log       hash (no arguments passed)
[bud@6.4.1] [app] › ✔  success   {"message":"file hashing enabled"}
[bud@6.4.1] [app] › log       runtime ["single"]
[bud@6.4.1] [app] › log       splitChunks (no arguments passed)
[bud@6.4.1] [app] [@roots/bud-preset-wordpress] › log       booted
[bud@6.4.1] [app] [@roots/bud-preset-wordpress] › ✔  success   imported @roots/bud-react
[bud@6.4.1] [app] › log       proxy ["https://tmnl.test/"]
[bud@6.4.1] [app] [bootstrap] › ✔  success   booted
[bud@6.4.1] [sage] › ✔  success   returning child instance: app
[bud@6.4.1] [sage] › ✔  success   returning child instance: app
[bud@6.4.1] [app] › log       entry [{"app":["@scripts/app","@styles/app"],"admin":["@styles/admin"],"login":["@styles/login"]}]
[bud@6.4.1] [app] › log       assets [["images"]]
[bud@6.4.1] [app] › log       provide [{"jquery":["jQuery","$"]}]
[bud@6.4.1] [app] › log       watch [["resources/views/**/*","app/**/*"]]
[bud@6.4.1] [app] › log       proxy ["https://tmnl.test"]
[bud@6.4.1] [app] › log       serve ["http://0.0.0.0:3000"]
[bud@6.4.1] [app] [@roots/sage/acorn] › ✔  success   unset entrypoints publicPath
[bud@6.4.1] [app] [@roots/sage/acorn] › ✔  success   unset manifest publicPath
[bud@6.4.1] [app] [@roots/bud-tailwindcss] › ✔  success   postcss configured for tailwindcss
[bud@6.4.1] [sage] › log       instantiating bud {...}
[bud@6.4.1] [editor] › ✔  success   logger ready
[bud@6.4.1] [editor] › ✔  success   imported env
[bud@6.4.1] [editor] › ✔  success   imported hooks
[bud@6.4.1] [editor] › ✔  success   imported api
[bud@6.4.1] [editor] › ✔  success   imported build
[bud@6.4.1] [editor] › ✔  success   imported cache
[bud@6.4.1] [editor] › ✔  success   imported extensions
[bud@6.4.1] [editor] › ✔  success   imported project
[bud@6.4.1] [editor] [bootstrap] › ✔  success   registered service callback: env.bootstrap
[bud@6.4.1] [editor] [bootstrap] › ✔  success   registered service callback: api.bootstrap
[bud@6.4.1] [editor] [bootstrap] › ✔  success   registered service callback: build.register
[bud@6.4.1] [editor] [bootstrap] › ✔  success   registered service callback: api.registered
[bud@6.4.1] [editor] [bootstrap] › ✔  success   registered service callback: cache.booted
[bud@6.4.1] [editor] [bootstrap] › ✔  success   registered service callback: extensions.booted
[bud@6.4.1] [editor] [bootstrap] › ✔  success   registered service callback: extensions.configAfter
[bud@6.4.1] [editor] [bootstrap] › ✔  success   registered service callback: extensions.buildBefore
[bud@6.4.1] [editor] [bootstrap] › ✔  success   registered service callback: extensions.buildAfter
[bud@6.4.1] [editor] [bootstrap] › ✔  success   registered service callback: project.buildAfter
[bud@6.4.1] [editor] [bootstrap] › ✔  success   init
[bud@6.4.1] [editor] [bootstrap] › ✔  success   bootstrap
[bud@6.4.1] [editor] [bootstrap] › ✔  success   bootstrapped
[bud@6.4.1] [editor] [bootstrap] › ✔  success   register
[bud@6.4.1] [editor] [bootstrap] › ✔  success   registered
[bud@6.4.1] [editor] [bootstrap] › ✔  success   boot
[bud@6.4.1] [editor] [@roots/bud-cache/invalidate-cache] › log       registered
[bud@6.4.1] [editor] › ✔  success   cache initialized
[bud@6.4.1] [editor] [extensions] › ✔  success   cdn imported and instantiated
[bud@6.4.1] [editor] [extensions] › ✔  success   esm imported and instantiated
[bud@6.4.1] [editor] [extensions] › ✔  success   fix-style-only-entrypoints imported and instantiated
[bud@6.4.1] [editor] [extensions] › ✔  success   clean-webpack-plugin imported and instantiated
[bud@6.4.1] [editor] [extensions] › ✔  success   webpack:provide-plugin imported and instantiated
[bud@6.4.1] [editor] [extensions] › ✔  success   webpack-manifest-plugin imported and instantiated
[bud@6.4.1] [editor] [extensions] › ✔  success   webpack:hot-module-replacement-plugin imported and instantiated
[bud@6.4.1] [editor] [extensions] › ✔  success   webpack:define-plugin imported and instantiated
[bud@6.4.1] [editor] [extensions] › ✔  success   mini-css-extract-plugin imported and instantiated
[bud@6.4.1] [editor] [extensions] › ✔  success   copy-webpack-plugin imported and instantiated
[bud@6.4.1] [editor] [extensions] › ✔  success   @roots/bud-eslint imported and instantiated
[bud@6.4.1] [editor] [extensions] › ✔  success   @roots/bud-prettier imported and instantiated
[bud@6.4.1] [editor] [extensions] › ✔  success   @roots/bud-stylelint imported and instantiated
[bud@6.4.1] [editor] [extensions] › ✔  success   @roots/bud-terser/css-minimizer imported and instantiated
[bud@6.4.1] [editor] [extensions] › ✔  success   @roots/bud-postcss imported and instantiated
[bud@6.4.1] [editor] [extensions] › ✔  success   @roots/sage/acorn imported and instantiated
[bud@6.4.1] [editor] [extensions] › ✔  success   @roots/bud-entrypoints imported and instantiated
[bud@6.4.1] [editor] [extensions] › ✔  success   @roots/bud-tailwindcss imported and instantiated
[bud@6.4.1] [editor] [extensions] › ✔  success   @roots/sage/wp-theme-json imported and instantiated
[bud@6.4.1] [editor] [extensions] › ✔  success   @roots/bud-terser imported and instantiated
[bud@6.4.1] [editor] [extensions] › ✔  success   @roots/bud-preset-recommend imported and instantiated
[bud@6.4.1] [editor] [extensions] › ✔  success   @roots/bud-wordpress-externals imported and instantiated
[bud@6.4.1] [editor] [extensions] › ✔  success   @roots/bud-wordpress-dependencies imported and instantiated
[bud@6.4.1] [editor] [extensions] › ✔  success   @roots/bud-preset-recommend imported and instantiated
[bud@6.4.1] [editor] [extensions] › ✔  success   @roots/bud-wordpress-manifests imported and instantiated
[bud@6.4.1] [editor] [extensions] › ✔  success   @roots/bud-react/react-refresh imported and instantiated
[bud@6.4.1] [editor] [extensions] › ✔  success   @roots/bud-react/react-refresh imported and instantiated
[bud@6.4.1] [editor] [extensions] › ✔  success   @roots/bud-react imported and instantiated
[bud@6.4.1] [editor] [extensions] › ✔  success   @roots/bud-react imported and instantiated
[bud@6.4.1] [editor] [extensions] › ✔  success   @roots/bud-preset-wordpress imported and instantiated
[bud@6.4.1] [editor] [extensions] › ✔  success   @roots/bud-preset-wordpress imported and instantiated
[bud@6.4.1] [editor] [extensions] › ✔  success   @roots/sage imported and instantiated
[bud@6.4.1] [editor] [webpack:define-plugin] › log       initialized
[bud@6.4.1] [editor] [@roots/sage/wp-theme-json] › log       initialized
[bud@6.4.1] [editor] [@roots/bud-eslint] › log       registered
[bud@6.4.1] [editor] [@roots/bud-postcss] › log       registered
[bud@6.4.1] [editor] [@roots/sage/acorn] › log       registered
[bud@6.4.1] [editor] [@roots/sage/acorn] › ✔  success   set svg generator path
[bud@6.4.1] [editor] [@roots/bud-terser] › log       registered
[bud@6.4.1] [editor] [@roots/bud-preset-recommend] › log       registered
[bud@6.4.1] [editor] [@roots/bud-preset-recommend] › ✔  success   imported @roots/bud-babel
[bud@6.4.1] [editor] [@roots/bud-babel] › log       initialized
[bud@6.4.1] [editor] [@roots/bud-babel] › log       registered
[bud@6.4.1] [editor] [@roots/bud-preset-wordpress] › log       registered
[bud@6.4.1] [editor] [@roots/sage] › log       registered
[bud@6.4.1] [editor] › log       alias [{"@fonts":"./resources/fonts","@images":"./resources/images","@scripts":"./resources/scripts","@styles":"./resources/styles"}]
[bud@6.4.1] [editor] › log       minimize (no arguments passed)
[bud@6.4.1] [editor] › log       hash (no arguments passed)
[bud@6.4.1] [editor] › ✔  success   {"message":"file hashing enabled"}
[bud@6.4.1] [editor] › log       runtime ["single"]
[bud@6.4.1] [editor] › log       splitChunks (no arguments passed)
[bud@6.4.1] [editor] [@roots/bud-preset-wordpress] › log       booted
[bud@6.4.1] [editor] [@roots/bud-preset-wordpress] › ✔  success   imported @roots/bud-react
[bud@6.4.1] [editor] › log       proxy ["https://tmnl.test/"]
[bud@6.4.1] [editor] [bootstrap] › ✔  success   booted
[bud@6.4.1] [sage] › ✔  success   returning child instance: editor
[bud@6.4.1] [sage] › ✔  success   returning child instance: editor
[bud@6.4.1] [editor] › log       entry [{"editor":["@scripts/editor","@styles/editor"]}]
[bud@6.4.1] [editor] [@roots/sage/acorn] › ✔  success   unset entrypoints publicPath
[bud@6.4.1] [editor] [@roots/sage/acorn] › ✔  success   unset manifest publicPath
[bud@6.4.1] [editor] [@roots/bud-tailwindcss] › ✔  success   postcss configured for tailwindcss
[bud@6.4.1] [sage] [@roots/bud-tailwindcss] › ✔  success   postcss configured for tailwindcss
[bud@6.4.1] [sage] [@roots/sage/acorn] › ✔  success   unset entrypoints publicPath
[bud@6.4.1] [sage] [@roots/sage/acorn] › ✔  success   unset manifest publicPath
[bud@6.4.1] [sage] [compiler] › log       imported webpack 5.73.0
[bud@6.4.1] [app] › log       bud.build.make called
[bud@6.4.1] [editor] › log       bud.build.make called
[bud@6.4.1] [app] [cdn] › log       buildBefore
[bud@6.4.1] [editor] [cdn] › log       buildBefore
[bud@6.4.1] [app] [@roots/bud-terser/css-minimizer] › log       buildBefore
[bud@6.4.1] [editor] [@roots/bud-terser/css-minimizer] › log       buildBefore
[bud@6.4.1] [app] [@roots/bud-terser] › log       buildBefore
[bud@6.4.1] [editor] [@roots/bud-terser] › log       buildBefore
[bud@6.4.1] [app] [build] › ✔  success   built bail
[bud@6.4.1] [app] [build] › ✔  success   built cache
[bud@6.4.1] [app] [build] › ✔  success   built context
[bud@6.4.1] [app] [build] › ✔  success   built entry
[bud@6.4.1] [app] [build] › ✔  success   built experiments
[bud@6.4.1] [app] [build] › ✔  success   built externalsType
[bud@6.4.1] [app] [build] › ✔  success   built infrastructureLogging
[bud@6.4.1] [app] [build] › ✔  success   built mode
[bud@6.4.1] [app] [build] › ✔  success   built name
[bud@6.4.1] [app] [build] › ✔  success   built node
[bud@6.4.1] [app] [build] › ✔  success   built optimization
[bud@6.4.1] [app] [build] › ✔  success   built output
[bud@6.4.1] [app] [build] › ✔  success   built parallelism
[bud@6.4.1] [app] [build] › ✔  success   built performance
[bud@6.4.1] [app] [@roots/bud-eslint] › ✔  success   produced webpack plugin
[bud@6.4.1] [app] [@roots/bud-stylelint] › ✔  success   produced webpack plugin
[bud@6.4.1] [app] [@roots/bud-entrypoints] › ✔  success   produced webpack plugin
[bud@6.4.1] [app] [@roots/bud-wordpress-externals] › ✔  success   produced webpack plugin
[bud@6.4.1] [app] [@roots/bud-wordpress-dependencies] › ✔  success   produced webpack plugin
[bud@6.4.1] [app] [@roots/bud-wordpress-manifests] › ✔  success   produced webpack plugin
[bud@6.4.1] [app] [build] › ✔  success   built recordsPath
[bud@6.4.1] [app] [build] › ✔  success   built stats
[bud@6.4.1] [app] [build] › ✔  success   built target
[bud@6.4.1] [editor] [build] › ✔  success   built bail
[bud@6.4.1] [editor] [build] › ✔  success   built cache
[bud@6.4.1] [editor] [build] › ✔  success   built context
[bud@6.4.1] [editor] [build] › ✔  success   built entry
[bud@6.4.1] [editor] [build] › ✔  success   built experiments
[bud@6.4.1] [editor] [build] › ✔  success   built externalsType
[bud@6.4.1] [editor] [build] › ✔  success   built infrastructureLogging
[bud@6.4.1] [editor] [build] › ✔  success   built mode
[bud@6.4.1] [editor] [build] › ✔  success   built name
[bud@6.4.1] [editor] [build] › ✔  success   built node
[bud@6.4.1] [editor] [build] › ✔  success   built optimization
[bud@6.4.1] [editor] [build] › ✔  success   built output
[bud@6.4.1] [editor] [build] › ✔  success   built parallelism
[bud@6.4.1] [editor] [build] › ✔  success   built performance
[bud@6.4.1] [editor] [@roots/bud-eslint] › ✔  success   produced webpack plugin
[bud@6.4.1] [editor] [@roots/bud-stylelint] › ✔  success   produced webpack plugin
[bud@6.4.1] [editor] [@roots/bud-entrypoints] › ✔  success   produced webpack plugin
[bud@6.4.1] [editor] [@roots/bud-wordpress-externals] › ✔  success   produced webpack plugin
[bud@6.4.1] [editor] [@roots/bud-wordpress-dependencies] › ✔  success   produced webpack plugin
[bud@6.4.1] [editor] [@roots/bud-wordpress-manifests] › ✔  success   produced webpack plugin
[bud@6.4.1] [editor] [build] › ✔  success   built recordsPath
[bud@6.4.1] [editor] [build] › ✔  success   built stats
[bud@6.4.1] [editor] [build] › ✔  success   built target
[bud@6.4.1] [app] [fix-style-only-entrypoints] › ✔  success   produced webpack plugin
[bud@6.4.1] [app] [clean-webpack-plugin] › ✔  success   produced webpack plugin
[bud@6.4.1] [app] [webpack:provide-plugin] › ✔  success   produced webpack plugin
[bud@6.4.1] [app] [webpack-manifest-plugin] › ✔  success   produced webpack plugin
[bud@6.4.1] [app] [mini-css-extract-plugin] › ✔  success   produced webpack plugin
[bud@6.4.1] [app] [copy-webpack-plugin] › ✔  success   produced webpack plugin
[bud@6.4.1] [app] [bud-cdn-gist] › ✔  success   produced webpack plugin
[bud@6.4.1] [editor] [fix-style-only-entrypoints] › ✔  success   produced webpack plugin
[bud@6.4.1] [editor] [clean-webpack-plugin] › ✔  success   produced webpack plugin
[bud@6.4.1] [editor] [webpack-manifest-plugin] › ✔  success   produced webpack plugin
[bud@6.4.1] [editor] [mini-css-extract-plugin] › ✔  success   produced webpack plugin
[bud@6.4.1] [editor] [bud-cdn-gist] › ✔  success   produced webpack plugin
[bud@6.4.1] [app] [build] › ✔  success   built module
[bud@6.4.1] [editor] [build] › ✔  success   built module
[bud@6.4.1] [app] [build] › ✔  success   built plugins
[bud@6.4.1] [editor] [build] › ✔  success   built plugins
[bud@6.4.1] [app] [build] › ✔  success   built resolve
[bud@6.4.1] [editor] [build] › ✔  success   built resolve
[bud@6.4.1] [app] [build] › ✔  success   configuration successfully built
[bud@6.4.1] [editor] [build] › ✔  success   configuration successfully built
[bud@6.4.1] [sage] [compiler] › log       child config app
[bud@6.4.1] [sage] [compiler] › log       child config editor

◉  app ./public/app [14ad60afe8254c85bb59]
│
├─ entrypoints
│ ├─ app
│ │ ├─ js/runtime.3e0a94.js     1.02 kB
│ │ ├─ js/329.cb1ac5.js       825.36 kB
│ │ ├─ css/app.932ff6.css      17.45 kB
│ │ └─ js/app.dda05a.js       293 bytes
│ ├─ admin
│ │ ├─ js/runtime.3e0a94.js     1.02 kB
│ │ └─ css/admin.90199c.css    44 bytes
│ └─ login
│   ├─ js/runtime.3e0a94.js     1.02 kB
│   └─ css/login.ec4c3a.css    28 bytes
│
├─ assets
│ ├─ images/tmnl_logo.805a34.svg                 23.3 kB
│ ├─ images/numbers/number-0-dark.21aa16.png     9.01 kB
│ ├─ images/numbers/number-5-dark.db74d2.png      7.5 kB
│ ├─ images/numbers/number-6-dark.db14a7.png     7.44 kB
│ └─ images/numbers/number-8-dark.5f4f0b.png     7.21 kB
│
│ … 6 additional asset(s) not shown
│
└─ compiled 56 modules in 4s 228ms


◉  editor ./public/editor [20fecc73885cbf5c00cd]
│
├─ entrypoints
│ └─ editor
│   ├─ js/runtime.d029f2.js      1.09 kB
│   ├─ js/256.0b4b57.js        280.27 kB
│   ├─ css/editor.31f388.css    17.67 kB
│   └─ js/editor.e2af05.js     946 bytes
│
│
└─ compiled 46 modules in 3s 358ms


✨  Done in 6.67s.

Configuration

// @ts-check

/**
 * Build configuration
 *
 * @see {@link https://bud.js.org/guides/configure}
 * @param {import('@roots/bud').Bud} app
 */
export default async bud => {
	/**
	 * Frontend css/js
	 *
	 * @param {bud} app
	 */
	await bud.make('app', async app =>
		app
			.setPath('@dist', 'public/app')
			.entry({
				app: ['@scripts/app', '@styles/app'],
				admin: ['@styles/admin'],
				login: ['@styles/login']
			})
			.assets(['images'])
			.provide({
				jquery: ['jQuery', '$']
			})
			.watch(['resources/views/**/*', 'app/**/*'])
			.proxy('https://sage.test')
			.serve('http://0.0.0.0:3000')
			.setPublicPath('/app/themes/sage/public/app/')
	)

	/**
	 * Editor css/js
	 *
	 * @param {bud} editor
	 */
	await bud.make('editor', async editor =>
		editor
			.setPath('@dist', 'public/editor')
			.entry({
				editor: ['@scripts/editor', '@styles/editor']
			})
			.postcss.setPlugin('postcss-editor-styles', [
				bud.module.resolve('postcss-editor-styles'), {
					scopeTo: '.editor-styles-wrapper :not(.acf-block-fields *)',
					tagSuffix: ':not([class^="components-"]):not([class^="editor-"]):not([class^="block-"]):not([aria-owns]):not([class^="acf-"]):not([id^="acf-"])'
				}
			])
	)
};

Relevant .budfiles

No response

@Twansparant Twansparant added the bug Something isn't working label Sep 23, 2022
@Twansparant Twansparant changed the title [bug] Multiple compilers not using bud-tailwindcss [bug] Multiple compilers not compiling tailwindcss Sep 23, 2022
@kellymears
Copy link
Member

Thanks for the issue. I'll need a little bit of time to replicate this on my end, but your issue is appreciated.

Question:

Does it seem like the other postcss plugin modification is being applied as expected (postcss-editor-styles)?

@Twansparant
Copy link
Sponsor Author

Does it seem like the other postcss plugin modification is being applied as expected (postcss-editor-styles)

Not 100% sure, have to get back to you about that, but don't think any postcss was applied. Don't think anything was prefixed in the compiled editor.css

@kellymears
Copy link
Member

Think I got it.

@kellymears
Copy link
Member

quick note:

right now you're defining the server config in the instance labeled app. you should define it in the context of the parent bud instance. the child instances don't have their own server.

export default async bud => {
  bud
    .watch([`resources/views/**/*`, `app/**/*`])
    .proxy(`https://sage.test`)
    .serve(`http://0.0.0.0:3000`);

  await bud.make(`app`, async app => app)
  await bud.make(`editor`, async editor => editor)
}

this isn't really documented properly. i've set up an issue to track.

kodiakhq bot pushed a commit that referenced this issue Sep 25, 2022
the `@once` decorator really means business. it's not per instance, it's static.

this means that only the first postcss extension would be registered in a multi-instance setup.

refers:

- #1702 

## Type of change

**PATCH: backwards compatible change**



This PR includes breaking changes to the following core packages:

- none

This PR includes breaking changes to the follow extensions:

- none

## Dependencies

### Adds

- none

### Removes

- none
@Twansparant
Copy link
Sponsor Author

right now you're defining the server config in the instance labeled app. you should define it in the context of the parent bud instance. the child instances don't have their own server.

Thanks for this! That was going to be my next question :)
What about the .setPublicPath, can that be defined per instance?

How can I actually test this fix patch in my project?
Thanks for your time so far, appreciate it!

@kellymears
Copy link
Member

kellymears commented Sep 26, 2022

@Twansparant setPublicPath can be set per instance.

as for testing..

this is the code that isn't getting called:

this.setPlugins({
import: await this.resolve(`postcss-import`),
nesting: await this.resolve(`postcss-nested`),
env: [
await this.resolve(`postcss-preset-env`).then(path =>
path.replace(`.mjs`, `.cjs`),
),
{
stage: 1,
features: {
'focus-within-pseudo-class': false,
},
},
],
})
this.app.build
.setLoader(`postcss`, await this.resolve(`postcss-loader`))
.setItem(`postcss`, {
loader: `postcss`,
options: () => ({
sourceMap: this.sourceMap,
postcssOptions: this.postcssOptions,
}),
})
this.app.build.rules.css.setUse(items => [...(items ?? []), `postcss`])
this.app.build.rules.cssModule?.setUse(items => [
...(items ?? []),
`postcss`,
])

you could clone this repo locally and run:

  • yarn
  • yarn @bud registry install
  • yarn @bud registry start
  • yarn @bud release --tag latest

and then in your project:

  • set the version of all @roots/* packages to 0.0.0
  • yarn install --registry http://localhost:4873

this basically makes a local registry and releases the packages to it. the --registry flag works with yarn and npm and will still resolve your project dependencies by proxying the npm registry when something isn't found locally.

when you're done you can kill the local registry:

  • yarn @bud registry stop

the yarn @bud commands must be run in repo root. the repo can be cloned anywhere on the machine.

@Twansparant
Copy link
Sponsor Author

Twansparant commented Sep 26, 2022

Nice, will test now!
Everything went smooth, until this step:

yarn @bud release --tag latest

which gives me an ECONNREFUSED error on some files:

➤ ➤ LICENSE.md
➤ ➤ README.md
➤ ➤ lib/env.d.ts
➤ ➤ lib/env.d.ts.map
➤ ➤ lib/env.js
➤ ➤ lib/env.js.map
➤ ➤ lib/extension.d.ts
➤ ➤ lib/extension.d.ts.map
➤ ➤ lib/extension.js
➤ ➤ lib/extension.js.map
➤ ➤ lib/index.d.ts
➤ ➤ lib/index.d.ts.map
➤ ➤ lib/index.js
➤ ➤ lib/index.js.map
➤ ➤ package.json
➤ ➤ RequestError: connect ECONNREFUSED 0.0.0.0:4873
➤     at ClientRequest.<anonymous> (/path/to/clone/bud/.yarn/releases/yarn-3.2.3.cjs:195:14361)
➤     at Object.onceWrapper (node:events:642:26)
➤     at ClientRequest.emit (node:events:539:35)
➤     at ClientRequest.o.emit (/path/to/clone/bud/.yarn/releases/yarn-3.2.3.cjs:190:90597)
➤     at Socket.socketErrorListener (node:_http_client:454:9)
➤     at Socket.emit (node:events:527:28)
➤     at emitErrorNT (node:internal/streams/destroy:164:8)
➤     at emitErrorCloseNT (node:internal/streams/destroy:129:3)
➤     at processTicksAndRejections (node:internal/process/task_queues:83:21)
➤     at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1187:16)
➤ ➤ Failed with errors in 7s 223ms

Therefore, running:

yarn install --registry http://localhost:4873

Results in the same ECONNREFUSED error:

error An unexpected error occurred: "http://localhost:4873/@roots%2fbud: connect ECONNREFUSED 127.0.0.1:4873".

I turned off my firewall, but that didn't help.
Probably it's failing because I'm on my office network? Does port 4873 need to be openend on the network?

@kellymears
Copy link
Member

yeah, unfortunately so.

just copy the modules out of node_modules/@roots. it's really just node_modules/@roots/bud-postcss/lib/extension.js that's important.

@Twansparant
Copy link
Sponsor Author

Twansparant commented Sep 26, 2022

Yes got it! Can confirm the fix works :)
Both stylesheets are compiled correctly now!
I did had to await the bud.module.resolve though:

await bud.make('editor', async editor =>
	editor
		.setPath('@dist', 'public/editor')
		.entry({
			editor: ['@scripts/editor', '@styles/editor']
		})
		.setPublicPath('/app/themes/sage/public/editor/')
		.postcss.setPlugin('postcss-editor-styles', [
			await bud.module.resolve('postcss-editor-styles'), {
				scopeTo: '.editor-styles-wrapper :not(.acf-block-fields *)',
				tagSuffix: ':not([class^="components-"]):not([class^="editor-"]):not([class^="block-"]):not([aria-owns]):not([class^="acf-"]):not([id^="acf-"])'
			}
		])
)

Somehow adding .setPublicPath as last function in the instance throws an error:

editor.setPath(...).entry(...).postcss.setPlugin(...).setPublicPath is not a function

Thank you so much!

@kellymears
Copy link
Member

kellymears commented Sep 27, 2022

Awesome.

You're getting an error because bud.postcss returns bud.postcss, not bud, and bud.postcss doesn't have a .setPublicPath method.

It returns it so that it's easier to chain bud.postcss calls. Demo below with indentation to better highlight where the break in the chain is:

export default async bud => {
  bud
    .setPath(`@dist`, `public/editor`) // returns `bud`
    .entry(`editor`, [`@scripts/editor`, `@styles/editor`]) // returns `bud`
    .postcss
      .setPlugin(`postcss-editor-styles`) // returns `bud.postcss`
      .setPluginOptions(
        `postcss-editor-styles`, 
        {scopeTo: `.foo`, tagSuffix: `:not(bar)`},
      ) // returns bud.postcss

    /**
     * This is going to error because `bud.postcss.setPublicPath` does not exist.
     */
    .setPublicPath(`/app/themes/sage/public/editor/`); // returns `bud`
}

Your solution (moving .setPublicPath up so that it chains off a function that returns bud) is a good one. But, if you are calling more than one thing that doesn't return bud you've still got options:

You could just forego the chaining entirely:

export default async bud => {
  bud.setPath(`@dist`, `public/editor`) // returns `bud`
  bud.entry(`editor`, [`@scripts/editor`, `@styles/editor`]) // returns `bud`
  bud.postcss.setPlugin(`postcss-editor-styles`) // returns `bud.postcss`
  bud.postcss.setPluginOptions(`postcss-editor-styles`, {}) // returns bud.postcss
  bud.babel.setPlugin(`@babel/plugin-transform-react-jsx`) // returns `bud.babel`
  bud.setPublicPath(`/app/themes/sage/public/editor/`); // returns `bud`
};

You could use bud.tap, which was designed for this:

export default async bud => {
  bud
    .setPath(`@dist`, `public/editor`) // returns `bud`
    .entry(`editor`, [`@scripts/editor`, `@styles/editor`]) // returns `bud`
    .tap(bud => bud.babel.setPlugin(`@babel/plugin-transform-react-jsx`)) // returns `bud`
    .tap(bud => bud.postcss.setPlugin(`postcss-editor-styles`)) // returns `bud`
    .setPublicPath(`/app/themes/sage/public/editor/`); // returns `bud`
}

@Twansparant
Copy link
Sponsor Author

Great, thanks for the extensive explanation!
Got it working with the .tap function!

@Twansparant
Copy link
Sponsor Author

Do you have any idea when you will release this fix patch?
Thanks!

@kellymears
Copy link
Member

Just released. Cheers!

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

No branches or pull requests

2 participants