11import { colors } from '../dist/index.js'
22import { shadows } from '../dist/index.js'
3+ import { breakpoints } from '../dist/index.js'
34import path from 'path'
45import * as fs from 'fs'
56const __dirname = path . resolve ( )
67
7- const writeJsObjectToLessFile = ( { jsObject, outPath } ) => {
8+ const writeJsObjectToLessFile = ( { jsObject, outPath, transform } ) => {
89 const outFileLines = [ ]
910 outFileLines . push ( '// THIS FILE WAS AUTOMATICALLY GENERATED' )
1011 Object . keys ( jsObject ) . forEach ( varName => {
11- outFileLines . push ( `@${ varName } : ${ jsObject [ varName ] } ;` )
12+ const value = transform ? transform ( jsObject [ varName ] ) : jsObject [ varName ]
13+ outFileLines . push ( `@${ varName } : ${ value } ;` )
1214 } )
1315 const finalOutput = `${ outFileLines . join ( '\n' ) } \n`
1416
@@ -22,3 +24,11 @@ console.log('Finished generating .less version of colors.ts...')
2224console . log ( 'Starting to generate .less version of shadows.ts...' )
2325writeJsObjectToLessFile ( { jsObject : shadows , outPath : `${ __dirname } /dist/shadows/shadows.less` } )
2426console . log ( 'Finished generating .less version of shadows.ts...' )
27+
28+ console . log ( 'Starting to generate .less version of breakpoints.ts...' )
29+ writeJsObjectToLessFile ( {
30+ jsObject : breakpoints ,
31+ outPath : `${ __dirname } /dist/breakpoints/breakpoints.less` ,
32+ transform : value => `~'only screen and (min-width: ${ value } px)'` ,
33+ } )
34+ console . log ( 'Finished generating .less version of breakpoints.ts...' )
0 commit comments