UNPKG

st-bundle

Version:

CLI for watching and bundling SpringType projects.

55 lines (54 loc) 2.35 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const path = require("path"); const plugin_json_1 = require("./plugin_json"); const plugin_link_1 = require("./plugin_link"); const plugin_less_1 = require("./plugin_less"); const createStylesheetProps_1 = require("../../config/createStylesheetProps"); const extensions_1 = require("../../config/extensions"); const plugin_stylus_1 = require("./plugin_stylus"); const plugin_raw_1 = require("./plugin_raw"); function pluginAssumption() { return (ctx) => { ctx.ict.on('bundle_resolve_module', props => { if (!props.module.captured) { const ext = path.extname(props.module.props.absPath); if (ext === '.json') { // json handler plugin_json_1.pluginJSONHandler(props.module, {}); } else if (extensions_1.LINK_ASSUMPTION_EXTENSIONS.indexOf(ext) > -1) { // Copy files and give it a link. // e.g import foo from "./foo.svg" plugin_link_1.pluginLinkHandler(props.module, {}); } else if (ext === '.less') { // CSS: Less extension plugin_less_1.pluginLessCapture({ ctx, module: props.module, opts: { stylesheet: createStylesheetProps_1.createStylesheetProps({ ctx, stylesheet: {} }), }, }); } else if (ext === '.styl') { // CSS: stylus plugin_stylus_1.pluginStylusCapture({ ctx, module: props.module, opts: { stylesheet: createStylesheetProps_1.createStylesheetProps({ ctx, stylesheet: {} }), }, }); } else if (extensions_1.TEXT_EXTENSIONS.indexOf(ext) > -1) { // Text extensions (like .md or text) plugin_raw_1.pluginRawHandler({ ctx, module: props.module, opts: {} }); } } return props; }); }; } exports.pluginAssumption = pluginAssumption;