Skip to content

Fix useminPrepare task to rewrite relative CSS urls - #1

Open
jridgewell wants to merge 1 commit into
masterfrom
usemin_css
Open

Fix useminPrepare task to rewrite relative CSS urls#1
jridgewell wants to merge 1 commit into
masterfrom
usemin_css

Conversation

@jridgewell

Copy link
Copy Markdown

First, tell useminPrepare to only 'cssmin' our CSS files (dropping the
concat task). See yeoman/grunt-usemin#225.
Second, tell cssmin to rewrite relative urls to be relative to our app
directory.

This is particularly useful for bower install components that have CSS
files that reference relative urls. ie.

.
├── app
│   └── bower_components
│       └── component
│           ├── images
│           │   └── image.png
│           └── style.css
└── build
body {
background: url('images/image.png');
}

Will have now properly rewrite it's image url to

body {
background: url('bower_components/component/images/image.png');
}

First, tell useminPrepare to only 'cssmin' our CSS files (dropping the
concat task). See yeoman/grunt-usemin#225.
Second, tell cssmin to rewrite relative urls to be relative to our app
directory.

This is particularly useful for bower install components that have CSS
files that reference relative urls. ie.

```
.
├── app
│   └── bower_components
│       └── component
│           ├── images
│           │   └── image.png
│           └── style.css
└── build
```

```
body {
background: url('images/image.png');
}
```

Will have now properly rewrite it's image url to
```
body {
background: url('bower_components/component/images/image.png');
}
```

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should remove one % here.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing a % would cause this line to be parsed while creating the app. See, for example, Lines 225-228

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah sure, my fault ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants