understrap/understrap

Dist build not creating assets

Closed this issue · 7 comments

Describe the problem
This might be my ignorance, but when I run dist-build, no build folder is created. I just see the build subfolder in the src folder. Where do the assets end up? I thought it created a build folder.

Debug Checklist
Please include all of the following:
Working with understrap child - v 1.1.0

  • [v16.18.0 ] The output of node -v
  • [git version 2.25.1 ] The output of git --version

Screenshots / Videos
If applicable, add screenshots/videos to help explain your problem.

Code
If applicable, provide code to help explain your problem.

Additional context
Is there documentation showing the folder structure after running the build script?

dist-build creates the folder dist not build.

Did you find the folder?

Thanks. Sorry I wasn't getting notifications. When I run dist-build I get this error:

`mlsmith45@Michael-Home:/mnt/d/WebProjects/adlerup/app/public/wp-content/themes/adler-understrap-child$ npm run dist-build

understrap-child@1.1.0 dist-build
node src/build/dist-build.js

node:internal/process/promises:279
triggerUncaughtException(err, true /* fromPromise */);
^

[Error: EACCES: permission denied, copyfile '.git/objects/00/65e60cba143e811fbdabde179831f84705b4c3' -> 'dist/.git/objects/00/65e60cba143e811fbdabde179831f84705b4c3'] {
errno: -13,
code: 'EACCES',
syscall: 'copyfile',
path: '.git/objects/00/65e60cba143e811fbdabde179831f84705b4c3',
dest: 'dist/.git/objects/00/65e60cba143e811fbdabde179831f84705b4c3'
}
mlsmith45@Michael-Home:/mnt/d/WebProjects/adlerup/app/public/wp-content/themes/adler-understrap-child$ `

Can you please try replacing the current content of src/build/dist-build.js with

const { promises: fs } = require( 'fs' );
const path = require( 'path' );

async function copyDir( src, dest ) {
	await fs.mkdir( dest, { recursive: true } );
	let entries = await fs.readdir( src, { withFileTypes: true } );
	// Exclude all dot files and directories.
	entries = entries.filter( dirent => ! dirent.name.startsWith('.') );
	const ignore = [
		'dist',
		'node_modules',
		'src',
		'vendor',
		'composer.json',
		'composer.lock',
		'package.json',
		'package-lock.json',
		'phpcs.xml.dist',
		'phpmd.baseline.xml',
		'phpmd.xml',
		'phpstan-baseline.neon',
		'phpstan.neon.dist',
	];

	for ( const entry of entries ) {
		if ( ignore.indexOf( entry.name ) != -1 ) {
			continue;
		}
		let srcPath = path.join( src, entry.name );
		let destPath = path.join( dest, entry.name );

		entry.isDirectory()
			? await copyDir( srcPath, destPath )
			: await fs.copyFile( srcPath, destPath );
	}
}

copyDir('./', './dist');

It also should be sufficient to do this in src/build/dist-build.js

	let ignore = [
		'node_modules',
		'dist',
		'src',
		'.github',
		'.browserslistrc',
		'.editorconfig',
		'.gitattributes',
		'.gitignore',
+               '.git',
		'.jscsrc',
		'.jshintignore',
		'.travis.yml',
		'composer.json',
		'composer.lock',
		'package.json',
		'package-lock.json',
		'phpcs.xml.dist',
		'readme.txt'
	];

However this #2094 (comment) is how we create the dist folder in the parent theme.

Thanks so much. I'll give this try later today. I'm away from my project atm.

That seems to have done it thanks!