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

Commit b3df023

Browse files
docs: Update getting started doc to use Sass module syntax (#5568)
FUTURE_COPYBARA_INTEGRATE_REVIEW=#5577 from crisbeto:mdc-chips-d-ts-error d154836 PiperOrigin-RevId: 293466751 Co-authored-by: Abhinay Omkar <[email protected]>
1 parent 3d771b3 commit b3df023

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed

docs/getting-started.md

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ To try Material Components for the web with minimal setup, load the precompiled
1313

1414
```html
1515
<head>
16-
<link href="https://unpkg.com/material-components-web@latest/dist/material-components-web.min.css" rel="stylesheet">
17-
<script src="https://unpkg.com/material-components-web@latest/dist/material-components-web.min.js"></script>
16+
<link href="https://unpkg.com/material-components-web@v4.0.0/dist/material-components-web.min.css" rel="stylesheet">
17+
<script src="https://unpkg.com/material-components-web@v4.0.0/dist/material-components-web.min.js"></script>
1818
</head>
1919
```
2020

@@ -82,16 +82,16 @@ We’re going to use `webpack-dev-server` to demonstrate how webpack bundles our
8282
You’ll need all of these Node dependencies:
8383
- [webpack](https://www.npmjs.com/package/webpack): Bundles Sass and JavaScript
8484
- [webpack-dev-server](https://www.npmjs.com/package/webpack-dev-server): Development server
85-
- [sass-loader](https://www.npmjs.com/package/sass-loader): Loads a Sass file and compiles it to CSS
86-
- [node-sass](https://www.npmjs.com/package/node-sass): Provides binding for Node.js to Sass, peer dependency to sass-loader
85+
- [sass-loader](https://www.npmjs.com/package/sass-loader): Webpack loader to preprocess Sass files
86+
- [sass](https://www.npmjs.com/package/sass): Sass compiler
8787
- [css-loader](https://www.npmjs.com/package/css-loader): Resolves CSS @import and url() paths
8888
- [extract-loader](https://github.com/peerigon/extract-loader): Extracts the CSS into a `.css` file
8989
- [file-loader](https://github.com/webpack-contrib/file-loader): Serves the `.css` file as a public URL
9090

9191
You can install all of them by running this command:
9292

9393
```
94-
npm install --save-dev webpack webpack-cli webpack-dev-server css-loader sass-loader node-sass extract-loader file-loader
94+
npm install --save-dev webpack webpack-cli webpack-dev-server css-loader sass-loader sass extract-loader file-loader
9595
```
9696

9797
In order to demonstrate how webpack bundles our Sass, you’ll need an `index.html`. This HTML file needs to include CSS. The CSS is generated by sass-loader, which compiles Sass files into CSS. The CSS is extracted into a `.css` file by extract-loader. Create this simple “hello world” `index.html`:
@@ -137,7 +137,13 @@ module.exports = [{
137137
},
138138
{ loader: 'extract-loader' },
139139
{ loader: 'css-loader' },
140-
{ loader: 'sass-loader' },
140+
{
141+
loader: 'sass-loader',
142+
options: {
143+
// Prefer Dart Sass
144+
implementation: require('sass'),
145+
},
146+
},
141147
]
142148
}
143149
]
@@ -166,11 +172,11 @@ npm install @material/button
166172
We need to tell our `app.scss` to import the Sass files for `@material/button`. We can also use Sass mixins to customize the button. Replace your “hello world” version of `app.scss` with this code:
167173

168174
```scss
169-
@import "@material/button/mdc-button";
175+
@use '@material/button/mdc-button';
176+
@use '@material/button';
170177

171178
.foo-button {
172-
@include mdc-button-ink-color(teal);
173-
@include mdc-states(teal);
179+
@include button.container-fill-color(darksalmon);
174180
}
175181
```
176182

@@ -180,9 +186,11 @@ We also need to configure sass-loader to understand the `@material` imports used
180186
{
181187
loader: 'sass-loader',
182188
options: {
189+
// Prefer Dart Sass
190+
implementation: require('sass'),
183191
sassOptions: {
184192
includePaths: ['./node_modules']
185-
}
193+
},
186194
}
187195
}
188196
```
@@ -226,7 +234,9 @@ Then add `postcss-loader`, using `autoprefixer` as a plugin:
226234
options: {
227235
sassOptions: {
228236
includePaths: ['./node_modules']
229-
}
237+
},
238+
// Prefer Dart Sass
239+
implementation: require('sass'),
230240
}
231241
},
232242
```
@@ -327,9 +337,11 @@ module.exports = {
327337
{
328338
loader: 'sass-loader',
329339
options: {
340+
// Prefer Dart Sass
341+
implementation: require('sass'),
330342
sassOptions: {
331343
includePaths: ['./node_modules'],
332-
}
344+
},
333345
},
334346
}
335347
],

0 commit comments

Comments
 (0)