Skip to content

Commit 6df5db7

Browse files
committed
chore: finalize colors lib
1 parent af37949 commit 6df5db7

File tree

9 files changed

+684
-1162
lines changed

9 files changed

+684
-1162
lines changed

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const rules = {
22
'no-bitwise': 'off',
3+
'import/no-extraneous-dependencies': 'off',
34
'no-param-reassign': [
45
'error',
56
{

TODO.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
- Remove
22
- Typography
33
- Lazy???
4-
- Colors
5-
- Move to build
6-
- White, black colors
7-
- make MD vars
84
- Update demos

package-lock.json

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
"@rollup/plugin-commonjs": "^23.0.0",
8585
"@rollup/plugin-node-resolve": "^15.0.0",
8686
"@rollup/plugin-replace": "^5.0.0",
87+
"@rollup/plugin-virtual": "^3.0.1",
8788
"@vitejs/plugin-vue": "^3.1.2",
8889
"@vue/compiler-sfc": "^3.2.40",
8990
"autoprefixer": "^10.4.12",
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
const fs = require('fs');
2+
const path = require('path');
3+
const { rollup } = require('rollup');
4+
const { nodeResolve } = require('@rollup/plugin-node-resolve');
5+
const commonjs = require('@rollup/plugin-commonjs');
6+
const virtual = require('@rollup/plugin-virtual');
7+
const { minify } = require('terser');
8+
9+
async function build(cb) {
10+
const outputFile = path.resolve(__dirname, '../src/core/shared/material-color-utils.js');
11+
await rollup({
12+
input: 'entry',
13+
plugins: [
14+
virtual({
15+
entry: `export { argbFromHex, hexFromArgb, themeFromSourceColor } from '@material/material-color-utilities';`,
16+
}),
17+
nodeResolve({ mainFields: ['module', 'main', 'jsnext'] }),
18+
commonjs(),
19+
],
20+
})
21+
.then((bundle) => {
22+
return bundle.write({
23+
strict: true,
24+
file: outputFile,
25+
format: 'esm',
26+
sourcemap: false,
27+
});
28+
})
29+
.then(async (bundle) => {
30+
const result = bundle.output[0];
31+
const minified = await minify(result.code, {
32+
mangle: false,
33+
format: {
34+
indent_level: 2,
35+
beautify: true,
36+
comments: false,
37+
preamble: '/* eslint-disable */',
38+
},
39+
});
40+
41+
fs.writeFileSync(outputFile, minified.code);
42+
})
43+
.catch((err) => {
44+
// eslint-disable-next-line
45+
console.log(err);
46+
});
47+
if (cb) cb();
48+
}
49+
50+
module.exports = build;

scripts/gulpfile.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const buildClean = require('./build-clean.js');
77

88
const buildKsCore = require('./build-ks-core.js');
99

10+
const buildMaterialColorUtils = require('./build-material-color-utils.js');
1011
const buildCoreJs = require('./build-core-js.js');
1112
const buildCoreTypings = require('./build-core-typings.js');
1213
const buildCoreLess = require('./build-core-styles.js');
@@ -26,6 +27,7 @@ const env = process.env.NODE_ENV || 'development';
2627
gulp.task('ks-core', buildKsCore);
2728

2829
gulp.task('core-clean', (cb) => buildClean('core', cb));
30+
gulp.task('core-material-color-utils', buildMaterialColorUtils);
2931
gulp.task('core-js', buildCoreJs);
3032
gulp.task('core-typings', buildCoreTypings);
3133
gulp.task('core-styles', buildCoreLess);
@@ -49,6 +51,7 @@ gulp.task(
4951
'build-core',
5052
gulp.series([
5153
'core-clean',
54+
'core-material-color-utils',
5255
...(env === 'development' ? [] : ['core-lazy-components']),
5356
'core-components',
5457
'core-js',

src/core/shared/material-color-utils.js

Lines changed: 603 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)