How to use the @stylable/core.createMinimalFS function in @stylable/core

To help you get started, we’ve selected a few @stylable/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wix / stylable / packages / core-test-kit / src / generate-test-util.ts View on Github external
export function generateInfra(
    config: InfraConfig,
    diagnostics: Diagnostics = new Diagnostics()
): {
    resolver: StylableResolver;
    requireModule: RequireType;
    fileProcessor: FileProcessor;
} {
    const { fs, requireModule } = createMinimalFS(config);

    const fileProcessor = cachedProcessFile(
        (from, content) => {
            const meta = process(postcss.parse(content, { from }), diagnostics);
            meta.namespace = config.files[from].namespace || meta.namespace;
            return meta;
        },
        fs,
        x => x
    );

    const resolver = new StylableResolver(fileProcessor, requireModule);

    return { resolver, requireModule, fileProcessor };
}
github wix / stylable / packages / core-test-kit / src / generate-test-util.ts View on Github external
export function createStylableInstance(config: Config) {
    config.trimWS = true;

    const { fs, requireModule } = createMinimalFS(config);

    const stylable = new Stylable(
        '/',
        fs as any,
        requireModule,
        '__',
        (meta, path) => {
            meta.namespace = config.files[path].namespace || meta.namespace;
            return meta;
        },
        undefined,
        undefined,
        config.resolve
    );

    return stylable;