-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Sass loader #4195
Merged
Merged
Sass loader #4195
Changes from 27 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
4b40a7d
Installs and adds sass loader task in webpack for dev environment.
Fabianopb 0670888
Uses Timer's branch of sass-loader without node-sass dependency.
Fabianopb fc1b9d4
Adds method for handling SASS modules.
Fabianopb ac4cf34
Fixes extension of excluded files when looking for scss modules.
Fabianopb 61bd312
Adds support for both .scss and .sass extensions.
Fabianopb 69ce2e6
Uses ExtractTextPlugin with sass-loader to bundle styles for the prod…
Fabianopb 0a81f2a
Bundles SASS modules for the production build.
Fabianopb 5a7f534
Uses the latest version of sass-loader.
Fabianopb b2573f5
Adds function to create different rules for style loaders in dev envi…
Fabianopb 6e60b6e
Abstracts style loaders to a common function to avoid repetition.
Fabianopb c8052c5
Simplifies the common function that creates style loaders.
Fabianopb 876c9b3
Creates assets for testing SASS/SCSS support.
Fabianopb 9865439
Creates mock components and unit tests for SASS and SCSS with and wit…
Fabianopb 1629d78
Creates integration tests for SASS/SCSS support.
Fabianopb 479423a
Adds node-sass as a template dependency so sass-loader can be tested.
Fabianopb dc640e4
Includes sass tests when test component is mounted.
Fabianopb f44250e
Fixes asserted module name for sass and scss modules tests.
Fabianopb 0f36d90
Removes tests against css imports in SCSS and SASS files.
Fabianopb c68d168
Merge branch 'next' of https://github.com/facebook/create-react-app i…
Fabianopb 7ba882e
Updates sass-loader to v7.
Fabianopb 2311570
Merge branch 'next' of https://github.com/facebook/create-react-app i…
Fabianopb 3657b78
Uses getCSSModuleLocalIdent from react-dev-utils.
Fabianopb 5a49244
Fixes tests to match the use of getCSSModuleLocalIdent.
Fabianopb 9e67bde
Improves readability of getStyleLoader function.
Fabianopb 4c14a2f
Uses postcss after sass.
Fabianopb 3b8bbb8
Refactors dev config to simplify common function for style loaders.
Fabianopb d9621fb
Refactors prod config to simplify common function for style loaders.
Fabianopb 22475dc
Use importLoaders config according to css-loader docs.
Fabianopb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
packages/react-scripts/fixtures/kitchensink/src/features/webpack/SassInclusion.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** | ||
* Copyright (c) 2015-present, Facebook, Inc. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import React from 'react'; | ||
import './assets/sass-styles.sass'; | ||
|
||
export default () => <p id="feature-sass-inclusion">We love useless text.</p>; |
17 changes: 17 additions & 0 deletions
17
packages/react-scripts/fixtures/kitchensink/src/features/webpack/SassInclusion.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* Copyright (c) 2015-present, Facebook, Inc. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import SassInclusion from './SassInclusion'; | ||
|
||
describe('sass inclusion', () => { | ||
it('renders without crashing', () => { | ||
const div = document.createElement('div'); | ||
ReactDOM.render(<SassInclusion />, div); | ||
}); | ||
}); |
13 changes: 13 additions & 0 deletions
13
packages/react-scripts/fixtures/kitchensink/src/features/webpack/SassModulesInclusion.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/** | ||
* Copyright (c) 2015-present, Facebook, Inc. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import React from 'react'; | ||
import styles from './assets/sass-styles.module.sass'; | ||
|
||
export default () => ( | ||
<p className={styles.sassModulesInclusion}>SASS Modules are working!</p> | ||
); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is
importLoaders: 1
not needed here? If not, can you please add a comment explaining why. It's not immediately obvious to me.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Timer, as far as I understood
importLoaders
here would allow e.g. to import SASS into CSS files, which is not common, and as SASS already handles imports, so this wouldn't be needed. Could anyone please confirm that just to see if I haven't misunderstood? webpack-contrib/css-loader#228There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could see someone importing a sass file in a css file; if there's no downsides/caveats we may as well add it and a corresponding test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact I've just tried importing a sass into a css and it works, so I wonder what's the use for
importLoaders
here?... Anyone with better understanding on thecss-loader
to give us a hint?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here is the original issue and attached diff adding this option, not sure if it'll help: webpack-contrib/css-loader#21
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated using
{importLoaders: 2}
according tocss-loader
docs: https://github.com/webpack-contrib/css-loader#importloaders