Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it up with sass-resources-loader #357

Merged
merged 6 commits into from
Oct 31, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions examples/basic/.bootstraprc-3-example
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ env:
- css-loader
- sass-loader
- postcss-loader
- sass-resources-loader?resources=app/styles/resources.scss
production:
extractStyles: true
styleLoaders:
- css-loader
- sass-loader
- postcss-loader
- sass-resources-loader?resources=app/styles/resources.scss

# Customize Bootstrap variables that get imported before the original Bootstrap variables.
# Thus original Bootstrap variables can depend on values from here. All the bootstrap
Expand Down
2 changes: 2 additions & 0 deletions examples/basic/.bootstraprc-4-example
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ env:
- css-loader
- sass-loader
- postcss-loader
- sass-resources-loader?resources=app/styles/resources.scss
production:
extractStyles: true
styleLoaders:
- css-loader
- sass-loader
- postcss-loader
- sass-resources-loader?resources=app/styles/resources.scss

# Extract styles to stand-alone css file
# Different settings for different environments can be used,
Expand Down
14 changes: 14 additions & 0 deletions examples/basic/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,17 @@ yarn run bs4:prod
# Run no config
yarn run bs:no-config
```

### Notes

`sass-resources-loader` imports specified SASS files into every SASS file it processes. In this particular case, `styleLoaders` are (Bootstrap 3, development):

```yaml
- style-loader
- css-loader
- sass-loader
- postcss-loader
- sass-resources-loader?resources=app/styles/resources.scss
```

So, `app/styles/resources.scss` is implicitly imported into `app/styles/bootstrap/pre-customizations.scss` among other things. There `$custom-border-radius` value is assigned to `$alert-border-radius`. You can see the alert affected at the bottom of the page.
4 changes: 4 additions & 0 deletions examples/basic/app/markup/bootstrap-dev.html
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ <h4 class="card-title">Card title</h4>
</div>
</div>

<div class="alert alert-info" role="alert">
You can use <code>sass-resources-loader</code> with <code>bootstrap-loader</code>
</div>

<div id="modal" class="modal fade">
<div class="modal-dialog" role="document">
<div class="modal-content">
Expand Down
4 changes: 4 additions & 0 deletions examples/basic/app/markup/bootstrap-prod.html
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ <h4 class="card-title">Card title</h4>
</div>
</div>

<div class="alert alert-info" role="alert">
You can use <code>sass-resources-loader</code> with <code>bootstrap-loader</code>
</div>

<div id="modal" class="modal fade">
<div class="modal-dialog" role="document">
<div class="modal-content">
Expand Down
2 changes: 2 additions & 0 deletions examples/basic/app/styles/bootstrap/pre-customizations.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ $fonts-url-path: "../fonts";
// $icon-font-path: ../fonts // This path is relative to this file
// $icon-font-name: 'glyphicons' // The name of the font you want to use
// And be sure to set useCustomIconFontPath to true in .bootstraprc.

$alert-border-radius: $custom-border-radius;
1 change: 1 addition & 0 deletions examples/basic/app/styles/resources.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$custom-border-radius: 50px;
3 changes: 2 additions & 1 deletion examples/basic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"scripts": {
"postinstall":
"rm -rf node_modules/bootstrap-loader && mkdir node_modules/bootstrap-loader && cd ../../ && yarn run build && cd - && cp -r ../../{package.json,loader.js,no-op.js,extractStyles.js,.bootstraprc-3-default,.bootstraprc-4-default,lib} node_modules/bootstrap-loader/ && cd node_modules/bootstrap-loader && yarn install --production",
"rm -rf node_modules/bootstrap-loader && mkdir -p node_modules/bootstrap-loader && cd ../../ && yarn run build && cd - && cp -r ../../{package.json,loader.js,no-op.js,extractStyles.js,.bootstraprc-3-default,.bootstraprc-4-default,lib} node_modules/bootstrap-loader/ && cd node_modules/bootstrap-loader && yarn install --production",
"start": "NODE_ENV=development nodemon --watch app/markup --ext html server.dev.js",
"clean": "rm -rf public/",
"cleanrc": "rm .bootstraprc || echo 'no .bootstraprc file to delete'",
Expand Down Expand Up @@ -39,6 +39,7 @@
"font-awesome": "^4.7.0",
"jquery": "3.3.1",
"popper.js": "1.14.3",
"sass-resources-loader": "^1.3.4",
"tether": "1.4.4"
},
"devDependencies": {
Expand Down
Loading