Skip to content
This repository was archived by the owner on Jan 31, 2025. It is now read-only.

Commit d4c632e

Browse files
committed
Improve README
1 parent 3651c78 commit d4c632e

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

README.md

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@ Starting with `1.0.0`, the sass-loader requires [node-sass](https://github.com/s
1313
[Documentation: Using loaders](http://webpack.github.io/docs/using-loaders.html)
1414

1515
``` javascript
16-
var css = require("!raw!sass!./file.scss");
16+
var css = require('!raw!sass!./file.scss');
1717
// => returns compiled css code from file.scss, resolves imports
18-
var css = require("!css!sass!./file.scss");
18+
var css = require('!css!sass!./file.scss');
1919
// => returns compiled css code from file.scss, resolves imports and url(...)s
2020
```
2121

2222
Use in tandem with the [`style-loader`](https://github.com/webpack/style-loader) to add the css rules to your document:
2323

2424
``` javascript
25-
require("!style!css!sass!./file.scss");
25+
require('!style!css!sass!./file.scss');
2626
```
2727

2828
### Apply via webpack config
@@ -35,14 +35,14 @@ module.exports = {
3535
loaders: [
3636
{
3737
test: /\.scss$/,
38-
loader: "style!css!sass"
38+
loader: 'style!css!sass'
3939
}
4040
]
4141
}
4242
};
4343
```
4444

45-
Then you only need to write: `require("./file.scss")`.
45+
Then you only need to write: `require('./file.scss')`.
4646

4747
### Sass options
4848

@@ -56,9 +56,9 @@ module.exports = {
5656
test: /\.scss$/,
5757
loader: "style!css!sass?outputStyle=expanded&" +
5858
"includePaths[]=" +
59-
(path.resolve(__dirname, "./bower_components")) + "&" +
59+
encodeURIComponent(path.resolve(__dirname, "./some-folder")) + "&" +
6060
"includePaths[]=" +
61-
(path.resolve(__dirname, "./node_modules"))
61+
encodeURIComponent(path.resolve(__dirname, "./another-folder"))
6262
}
6363
]
6464
}
@@ -69,7 +69,7 @@ See [node-sass](https://github.com/andrew/node-sass) for all available options.
6969

7070
### Imports
7171

72-
webpack provides an [advanced mechanism to resolve files](http://webpack.github.io/docs/resolving.html). The sass-loader uses node-sass' custom importer feature to pass all queries to the webpack resolving engine. Thus you can import your sass-modules from `node_modules`. Just prepend them with a `~` which tells webpack to look-up the [`modulesDirectories`](http://webpack.github.io/docs/configuration.html#resolve-modulesdirectories)
72+
webpack provides an [advanced mechanism to resolve files](http://webpack.github.io/docs/resolving.html). The sass-loader uses node-sass' custom importer feature to pass all queries to the webpack resolving engine. Thus you can import your sass-modules from `node_modules`. Just prepend them with a `~` which tells webpack to look-up the [`modulesDirectories`](http://webpack.github.io/docs/configuration.html#resolve-modulesdirectories).
7373

7474
```css
7575
@import "~bootstrap/less/bootstrap";
@@ -95,9 +95,14 @@ module.exports = {
9595
};
9696
```
9797

98-
### Importing across language styles
98+
### Problems with `url(...)`
9999

100-
Importing a file written in the other language style, like importing a `.sass` file from a `.scss` file, requires the file extension to be set explicitly. If no extension is specified, the extension is inherited from the importing file.
100+
Since Sass/[libsass](https://github.com/sass/libsass) does not provide [url rewriting](https://github.com/sass/libsass/issues/532), all linked assets must be relative to the output.
101+
102+
- If you're just generating CSS without passing it to the css-loader, it must be relative to your web root.
103+
- If you pass the generated CSS on to the css-loader, all urls must be relative to the entry-file (e.g. `main.scss`).
104+
105+
Library authors usually provide a variable to modify the asset path. [bootstrap-sass](https://github.com/twbs/bootstrap-sass) for example has an `$icon-font-path`. Check out [this example](https://github.com/jtangelder/sass-loader/tree/master/test/bootstrapSass).
101106

102107
## Source maps
103108

0 commit comments

Comments
 (0)