Skip to content
This repository has been archived by the owner on Oct 10, 2022. It is now read-only.

Build: If no SCSS files, don't attempt to build CSS files #115

Open
Viper007Bond opened this issue Dec 6, 2018 · 3 comments
Open

Build: If no SCSS files, don't attempt to build CSS files #115

Viper007Bond opened this issue Dec 6, 2018 · 3 comments

Comments

@Viper007Bond
Copy link

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

  1. Remove .scss file(s) from src directory.
  2. Run npm run build.

Real world example repository: https://github.com/Viper007Bond/syntaxhighlighter

  1. node -v: v10.14.1

  2. npm -v: 6.4.1

  3. yarn --version (if you use Yarn): 1.12.3 but not using Yarn in this case

  4. npm ls cgb-scripts (if you haven’t ejected): 1.13.0

  5. 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

@khylias
Copy link

khylias commented Jan 3, 2020

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.

@ghost
Copy link

ghost commented Feb 17, 2020

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.

@Acika00mk
Copy link

Acika00mk commented Apr 13, 2020

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

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

No branches or pull requests

3 participants