mirror of
https://github.com/papercss/papercss
synced 2024-05-23 08:02:19 +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 path = require('path');
|
||||||
const sass = require('sass');
|
const sass = require('sass');
|
||||||
const chalk = require('chalk');
|
const chalk = require('chalk');
|
||||||
|
@ -7,32 +8,42 @@ const postcss = require('postcss');
|
||||||
const cssnano = require('cssnano');
|
const cssnano = require('cssnano');
|
||||||
const autoprefixer = require('autoprefixer');
|
const autoprefixer = require('autoprefixer');
|
||||||
|
|
||||||
|
function log(...args) {
|
||||||
|
return console.log('📦', chalk.cyan(...args));
|
||||||
|
}
|
||||||
|
|
||||||
async function build() {
|
async function build() {
|
||||||
const entrypoint = path.resolve(__dirname, '../src/styles.scss');
|
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...'));
|
log('Starting PaperCSS build...');
|
||||||
console.log('📦', chalk.cyan('Cleaning dist/ folder...'));
|
log('Cleaning "dist/, docs/static/assets/paper.css" folder...');
|
||||||
|
|
||||||
rimraf.sync('dist', { disableGlob: true });
|
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 });
|
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 });
|
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 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');
|
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(paperminpath, minifiedCSS.css);
|
||||||
|
write(paperDocsPath, autoprefixedCSS.css);
|
||||||
|
|
||||||
console.log('📦', chalk.cyan('Build done!'));
|
log('Build done!');
|
||||||
}
|
}
|
||||||
|
|
||||||
build();
|
build();
|
||||||
|
|
Loading…
Reference in a new issue