JPeer264 / grunt-rcs

The grunt task to the main module rename-css-selectors
MIT License
2 stars 0 forks source link

Does not match strings as expected #1

Closed debanjanbasu closed 7 years ago

debanjanbasu commented 7 years ago

The RCS is breaking while there are certain code blocks inside the html, such as comments to target IE specific code.

JPeer264 commented 7 years ago

Can you provide a sample where it does not work? Is there also any error?

debanjanbasu commented 7 years ago
Code sample ```html AFR template

Before the Bell

Friday, 4th March, 2016


Strap 5l-5l

  • SPI up 8 points at 5382
  • AUD at US74.73 cents
  • Dow Jones +0.4%
  • S&P500 +0.3%
  • Nasdaq +0.3%
  • FTSE100 +0.3%
  • CAC -0.6%
  • DAX -0.7%
  • Spot gold +1.4% at $US1261.92 an ounce
  • Brent oil +2.1% at $US52.54 a barrel
  • Iron ore +0.04% at $US52.56 a tonne

Strap 5l-5l

  • CAC -0.6%
  • DAX -0.7%
  • Spot gold +1.4% at $US1261.92 an ounce
  • Brent oil +2.1% at $US52.54 a barrel
  • Iron ore +0.04% at $US52.56 a tonne

Strap xl

Duncan Jones steps out of dad David Bowie's shadow with Warcraft

This is optional wof text, configurable on/off in CQ author, and usually turned on for the larger stacked stories.


Duncan Jones steps out of dad David Bowie's shadow with Warcraft

This is optional wof text, configurable on/off in CQ author, and usually turned on for the larger stacked stories.


Duncan Jones steps out of dad David Bowie's shadow with Warcraft

This is optional wof text, configurable on/off in CQ author, and usually turned on for the larger stacked stories.


Strap 1s-2l

The mum who let five strangers breastfeed her baby

This is optional wof text, configurable on/off in CQ author, and usually turned on for the larger stacked stories.

Mum's loving kiss leaves baby fighting for life

This is optional wof text, configurable on/off in CQ author, and usually turned on for the larger stacked stories.

Sponsored

John, Jake and Harry: the who's who of Taylor Swift breakup songs

This is optional wof text, configurable on/off in CQ author, and usually turned on for the larger stacked stories.

Image description

John, Jake and Harry: the who's who of Taylor Swift breakup songs

This is optional wof text, configurable on/off in CQ author, and usually turned on for the larger stacked stories.

Image description

John, Jake and Harry: the who's who of Taylor Swift breakup songs

This is optional wof text, configurable on/off in CQ author, and usually turned on for the larger stacked stories.

Image description

```

This is the sample HTML file. All the conditional HTML code is causing the following code to be ignored. There is no error while compiling though. It is just not rewriting the classes and the ids in the HTML.

JPeer264 commented 7 years ago

Well yeah, I figured that there is a small bug in my regex. Actually it should just trigger everything between " " and ' '. As it is now it will also start at words like doesn't or it's. A quick fix for you might be to encode all ' as ' and " as " in your plain text or comments.

I will give you an update as soon as I solved this problem.

JPeer264 commented 7 years ago

Please try it again with v0.0.3

debanjanbasu commented 7 years ago

v0.0.3 seems to not compile the CSS at all. This is my grunt config :

rcs: {
    options: {},
    css: {
        options: {
            replaceCss: true
        },
        files: [{
            expand: true,
            cwd: 'dev/',
            src: 'csso/*.css',
            dest: 'rcs/',
        }]
    },
    all: {
        files: [{
            expand: true,
            cwd: 'dev/',
            src: ['*.html'],
            dest: 'rcs/',
        }]
    }
}
JPeer264 commented 7 years ago

Hm weird. I made now a project with your config where all CSS files in ./dev/csso and all HTML files in ./dev got compiled.

Please also make sure that rcs:css is loaded before rcs:all. Try following for me:

  1. Delete the rcs folder
  2. Make sure your paths in the grunt config are correct
  3. Run in your shell grunt rcs:css rcs:all

What is the output now?

debanjanbasu commented 7 years ago

It worked 👍 The trick is to ensure that the input CSS is not uglified (in one line). If the sass-->css is compact, it won't work. It has to be 'compressed'. I.e. CSS selector in it's own line.

JPeer264 commented 7 years ago

I am glad that it worked.

Oh that is a good hint. I will put this into the readme. Thanks!