esbuild-css-modules-server-plugin
Advanced tools
Comparing version 0.1.1 to 0.1.2
import { Plugin } from 'esbuild'; | ||
declare const pluginFactory: () => Plugin; | ||
export interface CSSServerPluginOptions { | ||
onCSSGenerated?: (css: string) => void; | ||
} | ||
declare const pluginFactory: (opts?: CSSServerPluginOptions) => Plugin; | ||
export default pluginFactory; | ||
//# sourceMappingURL=esbuildCssModulesServerPlugin.d.ts.map |
@@ -8,19 +8,27 @@ "use strict"; | ||
const node_css_require_1 = require("node-css-require"); | ||
const cssServerPlugin = { | ||
name: 'css-plugin-server', | ||
setup: (build) => { | ||
build.onLoad({ | ||
filter: /\.css$/, | ||
}, async (args) => { | ||
const text = await fs_1.default.promises.readFile(args.path, 'utf8'); | ||
const js = (0, node_css_require_1.compileCss)(text, args.path).js; | ||
return { | ||
contents: js, | ||
loader: 'js', | ||
}; | ||
}); | ||
}, | ||
const cssServerPlugin = (opts) => { | ||
return { | ||
name: 'css-plugin-server', | ||
setup: (build) => { | ||
build.onLoad({ | ||
filter: /\.css$/, | ||
}, async (args) => { | ||
const text = await fs_1.default.promises.readFile(args.path, 'utf8'); | ||
const res = (0, node_css_require_1.compileCss)(text, args.path); | ||
const js = res.js; | ||
if (opts === null || opts === void 0 ? void 0 : opts.onCSSGenerated) { | ||
opts.onCSSGenerated(res.css); | ||
} | ||
return { | ||
contents: js, | ||
loader: 'js', | ||
}; | ||
}); | ||
}, | ||
}; | ||
}; | ||
const pluginFactory = () => cssServerPlugin; | ||
const pluginFactory = (opts) => { | ||
return cssServerPlugin(opts); | ||
}; | ||
exports.default = pluginFactory; | ||
//# sourceMappingURL=esbuildCssModulesServerPlugin.js.map |
{ | ||
"name": "esbuild-css-modules-server-plugin", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "esbuild plugin for bundling CSS module files for server-side rendering", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5525
38