1
1
mirror of https://github.com/primer/css.git synced 2024-11-22 01:53:17 +03:00

Convert build tools to use dart-sass (#1617)

* Installing dart-sass

* Moving css compiling to separate file

* Removing node version

* Create polite-mayflies-refuse.md

* Don't compile support files

* Fix test to not check support

* Create olive-ants-kick.md
This commit is contained in:
Jon Rohan 2021-09-23 17:49:00 -07:00 committed by GitHub
parent 122eb0ecd9
commit e47324faa4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 490 additions and 1089 deletions

View File

@ -0,0 +1,5 @@
---
"@primer/css": major
---
Removing `<kbd>` import from markdown package. Going forward you'll need to include `@primer/css/base/kbd.scss` directly.

View File

@ -0,0 +1,5 @@
---
"@primer/css": minor
---
Convert postcss build tool, from node-sass to dart-sass.

View File

@ -1 +0,0 @@
14.15.2

1
.nvmrc
View File

@ -1 +0,0 @@
.node-version

View File

@ -22,6 +22,7 @@ describe('./dist/ folder', () => {
it('contains source maps', () => {
for (const file of distCSS) {
if (file.includes('support')) { continue }
expect(distMap).toContain(`${file}.map`)
}
})

View File

@ -78,3 +78,10 @@ See [color utility classes](/utilities/colors) for a list of all the functional
| `.text-inherit` | `.color-fg-inherit` |
A few more selectors and variables were removed. Please refer to [deprecations.json](https://github.com/primer/css/blob/main/src/deprecations.json) for a complete list.
Note: The `<kbd>` styles also got removed from the markdown bundle. In case you import the `markdown` bundle **without** the `base` bundle, make sure to import the `<kbd>` styles as well:
```diff
@import "@primer/css/markdown/index.scss";
+ @import "@primer/css/base/kbd.scss";
```

View File

@ -40,6 +40,7 @@
"@changesets/changelog-github": "0.4.1",
"@changesets/cli": "2.17.0",
"@github/prettier-config": "0.0.4",
"@koddsson/postcss-sass": "5.0.0",
"autoprefixer": "10.3.4",
"cssstats": "4.0.2",
"eslint": "7.32.0",
@ -56,7 +57,6 @@
"postcss-calc": "8.0.0",
"postcss-import": "14.0.2",
"postcss-load-config": "3.1.0",
"postcss-node-sass": "3.1.1",
"postcss-scss": "4.0.0",
"postcss-simple-vars": "6.0.3",
"prettier": "2.4.1",

View File

@ -1,16 +0,0 @@
const path = require('path')
module.exports = {
parser: 'postcss-scss',
map: {
sourcesContent: true,
annotation: true
},
plugins: [
require('postcss-node-sass')({
includePaths: [path.join(__dirname, 'node_modules')],
outputStyle: 'compressed'
}),
require('autoprefixer')
]
}

27
postcss.config.js Normal file
View File

@ -0,0 +1,27 @@
import autoprefixer from 'autoprefixer'
import sass from '@koddsson/postcss-sass'
import scss from 'postcss-scss'
import scssImport from 'postcss-import'
import {fileURLToPath} from 'url'
import {join, dirname} from 'path'
const __dirname = dirname(fileURLToPath(import.meta.url))
const plugins = [
scssImport,
sass({
includePaths: [join(__dirname, 'node_modules')],
outputStyle: process.env.CSS_MINIFY === '0' ? 'expanded' : 'compressed'
}),
autoprefixer,
];
export default {
map: {
sourcesContent: false,
annotation: true
},
syntax: scss,
parser: scss,
plugins: plugins
}

View File

@ -1,8 +1,7 @@
#!/usr/bin/env node
import {globby} from 'globby'
import compiler from './primer-css-compiler.js'
import cssstats from 'cssstats'
import postcss from 'postcss'
import loadConfig from 'postcss-load-config'
import {dirname, join} from 'path'
import analyzeVariables from './analyze-variables.js'
@ -27,8 +26,6 @@ const bundleNames = {
async function dist() {
try {
const bundles = {}
const {plugins, options} = await loadConfig()
const processor = postcss(plugins)
await remove(outDir)
await mkdirp(statsDir)
@ -53,7 +50,8 @@ async function dist() {
const scss = await readFile(from, encoding)
meta.imports = getExternalImports(scss, path).map(getPathName)
const result = await processor.process(scss, Object.assign({from, to}, options))
const result = await compiler(scss, {from, to})
await Promise.all([
writeFile(to, result.css, encoding),
writeFile(meta.stats, JSON.stringify(cssstats(result.css)), encoding),

View File

@ -0,0 +1,12 @@
import postcss from 'postcss'
import postCssConfig from '../postcss.config.js'
export default async function compiler(css, options) {
const { plugins, ...config } = postCssConfig
const result = await postcss(plugins).process(css, {
...config,
...options
})
return result
}

View File

@ -10,8 +10,6 @@
line-height: $body-line-height;
word-wrap: break-word;
@import "../base/kbd.scss"; // adds support for keyboard shortcuts
// Clearfix on the markdown body
&::before {
display: table;

1492
yarn.lock

File diff suppressed because it is too large Load Diff