How to use the @stylable/optimizer.StylableOptimizer function in @stylable/optimizer

To help you get started, we’ve selected a few @stylable/optimizer 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 / cli / src / build.ts View on Github external
const outPath = outSrcPath + '.js';
    const fileDirectory = dirname(filePath);
    const outDirPath = dirname(outPath);
    const cssAssetFilename = nameTemplate(outputCSSNameTemplate, {
        filename: basename(outSrcPath, '.st.css')
    });
    const cssAssetOutPath = join(dirname(outSrcPath), cssAssetFilename);

    log('[Build]', filePath + ' --> ' + outPath);
    tryRun(() => ensureDirectory(outDirPath, fs), `Ensure directory: ${outDirPath}`);
    const content = tryRun(
        () => fs.readFileSync(filePath).toString(),
        `Read File Error: ${filePath}`
    );
    const res = stylable.transform(content, filePath);
    const optimizer = new StylableOptimizer();
    if (optimize) {
        optimizer.optimize(
            {
                removeComments: true,
                removeEmptyNodes: true,
                removeStylableDirectives: true,
                classNameOptimizations: false,
                removeUnusedComponents: false
            },
            res,
            {}
        );
    }
    handleDiagnostics(diagnostics, res, diagnosticsMsg, filePath);
    // st.css
    if (outputSources) {
github wix / stylable / packages / webpack-plugin / src / stylable-webpack-plugin.ts View on Github external
// meta.namespace = getNamespaceFromBuiltStylsheet()
                // TODO: move to stylable as param.
                if (this.options.optimize.shortNamespaces) {
                    meta.namespace = stylable.optimizer!.namespaceOptimizer.getNamespace(
                        meta,
                        compiler.context,
                        stylable
                    );
                }
                return meta;
            },
            undefined,
            this.options.transformHooks,
            compiler.options.resolve,
            this.options.optimizer || new StylableOptimizer(),
            compiler.options.mode as any,
            this.options.resolveNamespace || resolveNamespace
        );
        this.stylable = stylable;
    }
    public injectPlugins(compiler: webpack.Compiler) {

@stylable/optimizer

Stylable core optimizer

MIT
Latest version published 5 months ago

Package Health Score

65 / 100
Full package analysis

Popular @stylable/optimizer functions