-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
2,568 additions
and
607 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/dist | ||
/src/design-tokens/generated | ||
/storybook-static |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/dist | ||
/storybook-static |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
## Publishing to npm | ||
|
||
1. `git checkout master` | ||
2. `git pull` | ||
3. Make sure you have a clean working tree (`git status` should show no changes) | ||
4. `npm publish` - This will automatically install and compile everything, run linting, and publish |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
const glob = require('tiny-glob'); | ||
const path = require('path'); | ||
|
||
/** @typedef {{file: string} | {contents: string} | null } ResolveResult */ | ||
|
||
/** | ||
* Custom glob importer | ||
* Needed to implement this because none of the sass glob importers on npm output @use | ||
* @param {string} url Raw path in source code | ||
* @param {string} currentPath Path to the current file | ||
* @param {(result: ResolveResult) => void} done Callback function for async resolvers | ||
* @returns {ResolveResult | void} | ||
*/ | ||
const globImporter = (url, currentPath, done) => { | ||
// This is a really lazy check but it is easy and good enough | ||
const isGlob = url.includes('*'); | ||
if (!isGlob) return null; | ||
glob(url, { cwd: path.dirname(currentPath) }).then((matchingPaths) => { | ||
// Generates a fake file that has the expanded @forward statements | ||
const contents = matchingPaths | ||
.map((filePath) => `@forward "${filePath}";`) | ||
.join('\n'); | ||
done({ contents }); | ||
}); | ||
}; | ||
|
||
module.exports = globImporter; |
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,62 @@ | ||
const { src, dest, parallel } = require('gulp'); | ||
|
||
const sass = require('gulp-sass'); | ||
const rename = require('gulp-rename'); | ||
const postcss = require('gulp-postcss'); | ||
const cssnano = require('cssnano'); | ||
|
||
const rollup = require('rollup'); | ||
const path = require('path'); | ||
const multiEntry = require('@rollup/plugin-multi-entry'); | ||
const nodeResolve = require('@rollup/plugin-node-resolve'); | ||
const { terser } = require('rollup-plugin-terser'); | ||
|
||
sass.compiler = require('sass'); | ||
|
||
const outDir = 'dist'; | ||
|
||
const buildSass = () => { | ||
return src('./src/index.scss') | ||
.pipe( | ||
sass({ | ||
importer: [ | ||
require('../../glob-sass-importer'), | ||
// Import Theo design tokens as SCSS variables | ||
require('../../.theo/sass-importer'), | ||
], | ||
}).on('error', sass.logError) | ||
) | ||
.pipe(rename({ basename: 'standalone' })) | ||
.pipe(dest(outDir)) | ||
.pipe(postcss([cssnano()])) | ||
.pipe(rename({ extname: '.min.css' })) | ||
.pipe(dest(outDir)); | ||
}; | ||
|
||
const buildJS = async () => { | ||
const pathName = 'cloudfour-patterns'; | ||
const globalName = 'cloudfourPatterns'; | ||
const bundle = await rollup.rollup({ | ||
input: 'src/{objects,components}/**/*.js', | ||
plugins: [multiEntry(), nodeResolve()], | ||
}); | ||
await Promise.all([ | ||
bundle.write({ format: 'esm', file: path.join(outDir, `${pathName}.mjs`) }), | ||
bundle.write({ | ||
format: 'umd', | ||
name: globalName, | ||
file: path.join(outDir, `${pathName}.js`), | ||
}), | ||
bundle.write({ | ||
format: 'umd', | ||
name: globalName, | ||
file: path.join(outDir, `${pathName}.min.js`), | ||
plugins: [terser()], | ||
}), | ||
]); | ||
}; | ||
|
||
const build = parallel(buildSass, buildJS); | ||
|
||
// Expose to Gulp | ||
module.exports = build; |
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
File renamed without changes.
Oops, something went wrong.