Node.js integration

Stylify can be used in two ways in the Node.js environment. Directly through @stylify/stylify or using the @stylify/bundler package.

Integration example for the Node.js can be found in integrations examples repository .

How to integrate the Stylify into the Node.js

You can either use Stylify directly or create a Bundler config.

Using @stylify/stylify directly

For more information see stylify documentation:

import { Compiler, nativePreset } from '@stylify/stylify';

const content = '';

const compiler = new Compiler(nativePreset.compiler);
const compilationResult = compiler.compile(content);
const css = compilationResult.generateCss();
const mangledContent = compiler.rewriteSelectors(content, compilationResult);

Using @stylify/bundler package

For more information see bundler documentation:

import { nativePreset } from '@stylify/stylify';
import { Bundler } from '@stylify/bundler';

const bundler = new Bundler({compiler: nativePreset.compiler})

bundler.bundle([
    {
        outputFile: 'path/to/output.css',
        files: ['path/to/layout.html', 'path/to/page.html']
    }
]);