create-guten-block
create-guten-block copied to clipboard
Build: If no SCSS files, don't attempt to build CSS files
Bug Report
My block doesn't have any custom styling to go with it, so I've removed the .scss
files:
https://github.com/Viper007Bond/syntaxhighlighter/tree/master/src
Expected Behavior
npm run build
would generate blocks.build.js
and that's it.
Actual Behavior
An error is thrown because the CSS file(s) don't exist.
Let's build and compile the files...
✅ Built successfully!
fs.js:115
throw err;
^
Error: ENOENT: no such file or directory, open '/mnt/c/work/wpdev/syntaxhighlighter/wordpress/wp-content/plugins/syntaxhighlighter/dist/blocks.editor.build.css'
at Object.openSync (fs.js:436:3)
at Object.readFileSync (fs.js:341:35)
at getFileSize (/mnt/c/work/wpdev/syntaxhighlighter/wordpress/wp-content/plugins/syntaxhighlighter/node_modules/cgb-scripts/scripts/build.js:50:37)
at compiler.run (/mnt/c/work/wpdev/syntaxhighlighter/wordpress/wp-content/plugins/syntaxhighlighter/node_modules/cgb-scripts/scripts/build.js:124:4)
at emitRecords.err (/mnt/c/work/wpdev/syntaxhighlighter/wordpress/wp-content/plugins/syntaxhighlighter/node_modules/webpack/lib/Compiler.js:265:13)
at Compiler.emitRecords (/mnt/c/work/wpdev/syntaxhighlighter/wordpress/wp-content/plugins/syntaxhighlighter/node_modules/webpack/lib/Compiler.js:371:38)
at emitAssets.err (/mnt/c/work/wpdev/syntaxhighlighter/wordpress/wp-content/plugins/syntaxhighlighter/node_modules/webpack/lib/Compiler.js:258:10)
at applyPluginsAsyncSeries1.err (/mnt/c/work/wpdev/syntaxhighlighter/wordpress/wp-content/plugins/syntaxhighlighter/node_modules/webpack/lib/Compiler.js:364:12)
at next (/mnt/c/work/wpdev/syntaxhighlighter/wordpress/wp-content/plugins/syntaxhighlighter/node_modules/tapable/lib/Tapable.js:218:11)
at Compiler.compiler.plugin (/mnt/c/work/wpdev/syntaxhighlighter/wordpress/wp-content/plugins/syntaxhighlighter/node_modules/webpack/lib/performance/SizeLimitsPlugin.js:99:4)
Steps to Reproduce
- Remove
.scss
file(s) fromsrc
directory. - Run
npm run build
.
Real world example repository: https://github.com/Viper007Bond/syntaxhighlighter
-
node -v
: v10.14.1 -
npm -v
: 6.4.1 -
yarn --version
(if you use Yarn): 1.12.3 but not using Yarn in this case -
npm ls cgb-scripts
(if you haven’t ejected): 1.13.0 -
Operating system: Ubuntu 18.04.1 via WSL in Windows 10
Possible Solution
Perhaps the minification script or something comes along second and tries to access the CSS file but it doesn't exist because it wasn't needed? A file exists check might fix it?
Reproducible Demo
https://github.com/Viper007Bond/syntaxhighlighter
Hi,
I've got the same error. But I work with 2 blocks in 2 separate CGB project. One has ejected webpack configuration and the other not. With just common.scss
, the second throw the error on build but not the first.
EDIT I eject CGB webpack configuration and I remove manually all configurations about styles. Work fine.
Getting the same error, since I don't need any styles in my blocks. Can this be fixed? Putting the files back into their folders is not fixing this issue.
As i see the issue is still opened. I have created a loophole, where i keep the files as empty, and ,most important ,keep the imports in the src/block/block.js
// Import CSS.
import './editor.scss';
import './style.scss';
remove the calls in register_block_type and wp_register_style functions
all will be good when you try to build it.
edit : Also you must keep the common.scss file