Home > Back-end >  ENOENT: no such file or directory, open 'G:\Aframara Website\images
ENOENT: no such file or directory, open 'G:\Aframara Website\images

Time:06-01

I have been trying to remove unused CSS from the style.css and in bootstrap.min.css in my website that is in development mode. Am using PostCSS & Parcel to do this.

So I installed both PostCSS and Parcel and then created a postcss.config.js.

The postcss.config.js has the following code

postcss.config.js

module.exports = {
    Plugins:[
        require("postcss-uncss")({
            html:[
             '/index.html'
            ]
        })
    ]
} 

When I run parcel index.html this error keeps showing up

G:\Aframara Website\images\about\ us.jpg: ENOENT: no such file or directory, open 'G:\Aframara Website\images\about\ us.jpg'

I have 7 Html files and the style.css as mentioned earlier together with bootstrap.min.css.

So I would like to reduce the size of all the two files. I watched this video and did exactly as he said. If anyone has another way I will appreciate thanks.

CodePudding user response:

I found a way around it, I Installed npm i -g purgecss

Then I created a folder with the title 'purged' at the root of my website.

I ran this command

purgecss --css *.css **/*.css --content *.html *.js --output purged

What this command did it created the two files i.e style.css and bootstrap.min.css in the folder purged.

Then I changed the css styles URL from css/bootstrap.min.css to purged/bootstrap.min.css and css/style.css to purged/style.css

The *.js is to check to see if you have any styles dynamically generated in javascript. You can leave it if you want.

The size of my two files bootstrap.min.css and style.css were reduced significantly.

  • Related