mirror of
https://github.com/papercss/papercss
synced 2024-05-12 02:36:40 +02:00
Write paper.css to docs assets, use logger function
This commit is contained in:
parent
40b4508032
commit
310797c92a
|
@ -1,3 +1,4 @@
|
|||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const sass = require('sass');
|
||||
const chalk = require('chalk');
|
||||
|
@ -7,32 +8,42 @@ const postcss = require('postcss');
|
|||
const cssnano = require('cssnano');
|
||||
const autoprefixer = require('autoprefixer');
|
||||
|
||||
function log(...args) {
|
||||
return console.log('📦', chalk.cyan(...args));
|
||||
}
|
||||
|
||||
async function build() {
|
||||
const entrypoint = path.resolve(__dirname, '../src/styles.scss');
|
||||
const paperDocsPath = path.resolve(__dirname, '../docs/static/assets/paper.css');
|
||||
|
||||
console.log('📦', chalk.cyan('Starting PaperCSS build...'));
|
||||
console.log('📦', chalk.cyan('Cleaning dist/ folder...'));
|
||||
log('Starting PaperCSS build...');
|
||||
log('Cleaning "dist/, docs/static/assets/paper.css" folder...');
|
||||
|
||||
rimraf.sync('dist', { disableGlob: true });
|
||||
fs.unlinkSync(paperDocsPath);
|
||||
|
||||
console.log('📦', chalk.cyan('Compiling SCSS to CSS, entrypoint:', entrypoint));
|
||||
log('Compiling SCSS to CSS, entrypoint:', entrypoint);
|
||||
|
||||
const compiledCSS = sass.renderSync({ file: entrypoint });
|
||||
|
||||
console.log('📦', chalk.cyan('Applying autoprefixer and cssnano...'));
|
||||
log('Processing CSS: autoprefixer...');
|
||||
|
||||
const autoprefixedCSS = await postcss([autoprefixer]).process(compiledCSS.css, { from: undefined });
|
||||
|
||||
log('Processing CSS: cssnano...');
|
||||
|
||||
const minifiedCSS = await postcss([cssnano]).process(autoprefixedCSS.css, { from: undefined });
|
||||
|
||||
const paperpath = path.resolve(__dirname, '../dist/paper.css');
|
||||
const paperPath = path.resolve(__dirname, '../dist/paper.css');
|
||||
const paperminpath = path.resolve(__dirname, '../dist/paper.min.css');
|
||||
|
||||
console.log('📦', chalk.cyan('Writing paper.css and paper.min.css files...'));
|
||||
log('Writing paper.css and paper.min.css files to dist/ and docs/ folders...');
|
||||
|
||||
write(paperpath, autoprefixedCSS.css);
|
||||
write(paperPath, autoprefixedCSS.css);
|
||||
write(paperminpath, minifiedCSS.css);
|
||||
write(paperDocsPath, autoprefixedCSS.css);
|
||||
|
||||
console.log('📦', chalk.cyan('Build done!'));
|
||||
log('Build done!');
|
||||
}
|
||||
|
||||
build();
|
||||
|
|
Loading…
Reference in a new issue