Comments (4)
Hi @markopredovic,
I haven't done this myself in PWA Studio yet but imagine you will need to:
Install the webpack sass-loader:
https://github.com/webpack-contrib/sass-loader
And update the webpack.config.js file to include something like.
config.module.rules.push({
test: /\.scss$/,
loaders: [
require.resolve('style-loader'),
{
loader: require.resolve('css-loader'),
options: {
localIdentName: '[path][name]__[local]--[hash:base64:5]',
modules: true,
},
},
{
loader: require.resolve('sass-loader'),
/**
* To prevent including the theme in every file we use the prependData attribute to load the theme
*/
options: {
prependData: '@import "./src/theme.scss";',
},
},
],
});
For more info see:
https://magento.github.io/pwa-studio/technologies/basic-concepts/css-modules/
Once you getting it working, it would be great if you could share it in a PR.
Thanks :)
from how-to-venia.
Thanks @rossmc , will do
from how-to-venia.
I ended with this configuration for now, it is not quite generic but ok, scss files with 'module' in name are scoped to component, also have global available scss styles in src root directory.
clientConfig.module.rules.push(
{
test: /\.module\.s(a|c)ss$/,
loaders: [
require.resolve('style-loader'),
{
loader: require.resolve('css-loader'),
options: {
localIdentName:
'[path][name]__[local]--[hash:base64:5]',
modules: true
}
},
{
loader: require.resolve('sass-loader')
/**
* To prevent including the theme in every file we use the prependData attribute to load the theme
*/
}
]
},
{
test: /s(a|c)ss$/,
exclude: /\.module.(s(a|c)ss)$/,
loaders: [
require.resolve('style-loader'),
{
loader: require.resolve('css-loader')
},
{
loader: require.resolve('sass-loader'),
/**
* To prevent including the theme in every file we use the prependData attribute to load the theme
*/
options: {
prependData: '@import "./src/styles/styles.scss";'
}
}
]
}
);
from how-to-venia.
oh this is great. Thanks @markopredovic.
At some point soon, I hope use this to update the css-modules doc with an Optionally Use SCSS section.
from how-to-venia.
Related Issues (3)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from how-to-venia.