JPeer264 / node-rename-css-selectors

📝 Rename css classes and id's in files
MIT License
65 stars 9 forks source link

Usage Instructions - Not working. #4

Closed QuantumRevenger closed 7 years ago

QuantumRevenger commented 7 years ago

When using the usage code it firstly highlights that the code is invalid, and attempting to fix it just does not work.

rcs.processCss('**/*.css', { overwrite: true, cwd: opt.dir, newPath: '' }, function(err) {
    // all css files are now saved, renamed and stored in the selectorLibrary

    // now it is time to process all other files
    rcs.process('**/*.js',  { overwrite: true, cwd: opt.dir, newPath: '' }, function(err) {
        // that's it
    });
    rcs.process('**/*.html',  { overwrite: true, cwd: opt.dir, newPath: '' }, function(err) {
        // that's it
    });
});

Nothing happens at all, it hangs for a while and eventually just exits with -1

The demo code / usage does not work at all and fails to include how to process html?

davewallace commented 7 years ago

@QuantumRevenger do you have a sample of the CSS you're trying to process? FWIW I hadn't tried overwrite: true and I do have this function successfully producing output. Does it make a difference when you switch it to false, just for a test?

JPeer264 commented 7 years ago

@QuantumRevenger first off you might want to nest your functions, as they are async:

rcs.processCss('**/*.css', { overwrite: true, cwd: opt.dir, newPath: '' }, function(errCss) {
    // all css files are now saved, renamed and stored in the selectorLibrary

    // now it is time to process all other files
    rcs.process('**/*.js',  { overwrite: true, cwd: opt.dir, newPath: '' }, function(errJs) {
        // that's it
       rcs.process('**/*.html',  { overwrite: true, cwd: opt.dir, newPath: '' }, function(errHtml) {
           // that's it
       });
    });
});

Secondly, I couldn't reproduce the error, it worked for me that way. Maybe you console.log the error inside, you might have no write rights?

I also just realized that it is pretty bad that it does not accept any Arrays as parameter, I will change that soon.

JPeer264 commented 7 years ago

@QuantumRevenger since v0.2.0 you can write it like following:


rcs.processCss('**/*.css', { overwrite: true, cwd: opt.dir, newPath: '' }, function(errCss) {
    // all css files are now saved, renamed and stored in the selectorLibrary

    // now it is time to process all other files
    rcs.process(['**/*.js', '**/*.html'],  { overwrite: true, cwd: opt.dir, newPath: '' }, function(err) {
        // that's it
    });
});
QuantumRevenger commented 7 years ago

It's now replacing files and renaming selectors in all files, but is breaking Javascript entirely.

It's replacing parts of function names, variables, base64 data, and more. Brutally rendering it unusable, like it's just applying a string replace without a care for integrity or validation?

JPeer264 commented 7 years ago

@QuantumRevenger It is also replacing function names and variables? Ok that is not the way it should work like.

Can you provide a short snippet how it looks like after you processed the data? Btw, your files should not be minified/uglified - if your files are.

JPeer264 commented 7 years ago

Closed as user did not respond