Last change
on this file since 6a3a178 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
906 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | /*
|
---|
| 2 | * This example targets Node 4 and up.
|
---|
| 3 | */
|
---|
| 4 |
|
---|
| 5 | const cssnano = require('cssnano');
|
---|
| 6 |
|
---|
| 7 | /*
|
---|
| 8 | * Add your CSS code here.
|
---|
| 9 | */
|
---|
| 10 |
|
---|
| 11 | const css = `
|
---|
| 12 | h1 {
|
---|
| 13 | color: #ff0000;
|
---|
| 14 | font-weight: bold;
|
---|
| 15 | }
|
---|
| 16 | `;
|
---|
| 17 |
|
---|
| 18 | /*
|
---|
| 19 | * Add any PostCSS options here. For example to enable sourcemaps, see:
|
---|
| 20 | * https://github.com/postcss/postcss/blob/master/site/source-maps.md
|
---|
| 21 | *
|
---|
| 22 | * Or for an inline sourcemap, uncomment the options below.
|
---|
| 23 | */
|
---|
| 24 |
|
---|
| 25 | const postcssOpts = {
|
---|
| 26 | // from: 'app.css',
|
---|
| 27 | // to: 'app.min.css',
|
---|
| 28 | // map: {inline: true},
|
---|
| 29 | };
|
---|
| 30 |
|
---|
| 31 | /*
|
---|
| 32 | * Add your choice of preset. Note that for any value other
|
---|
| 33 | * than 'default', you will need to install the appropriate
|
---|
| 34 | * preset separately.
|
---|
| 35 | */
|
---|
| 36 |
|
---|
| 37 | const cssnanoOpts = {
|
---|
| 38 | preset: 'default',
|
---|
| 39 | };
|
---|
| 40 |
|
---|
| 41 | /*
|
---|
| 42 | * Compress the CSS asynchronously and log it to the console.
|
---|
| 43 | */
|
---|
| 44 |
|
---|
| 45 | cssnano.process(css, postcssOpts, cssnanoOpts).then((result) => {
|
---|
| 46 | // eslint-disable-next-line no-console
|
---|
| 47 | console.log(result.css);
|
---|
| 48 | });
|
---|
Note:
See
TracBrowser
for help on using the repository browser.