How to use the @stylable/core.Stylable 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 / webpack-plugin / src / stylable-webpack-plugin.ts View on Github external
public createStylable(compiler: webpack.Compiler) {
        const stylable = new Stylable(
            compiler.context,
            (compiler.inputFileSystem as any).fileSystem || (compiler.inputFileSystem as any),
            this.options.requireModule,
            '__',
            meta => {
                if (this.options.unsafeBuildNamespace) {
                    try {
                        meta.namespace = require(meta.source + '.js').namespace;
                    } catch {
                        /* */
                    }
                }

                // meta.namespace = getNamespaceFromBuiltStylsheet()
                // TODO: move to stylable as param.
                if (this.options.optimize.shortNamespaces) {
github wix / stylable / packages / language-service / test-kit / stylable-fixtures-lsp.ts View on Github external
import { StylableLanguageService } from '../src/lib/service';

export const CASES_PATH = fs.join(
    fs.dirname(fs.findClosestFileSync(__dirname, 'package.json')!),
    'test',
    'fixtures',
    'server-cases'
);

function requireModule(request: string) {
    return require(require.resolve(request, { paths: [CASES_PATH] }));
}

export const stylableLSP = new StylableLanguageService({
    fs,
    stylable: new Stylable(CASES_PATH, fs as any, requireModule)
});
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;
}