any-file-merge

1.0.3 • Public • Published

Installation

npm install any-file-merge

Usage

predefined processors

const fs = require('fs');
const { AnyFileMerge, Html, Js, Css } = require('any-file-merge');
const config = {
    output: './output',
    fileName: 'merged-[name].html',
    processors: [
        new Html(),
        new Js(),
        new Css()
    ]
};
const sc = new AnyFileMerge(fs, config);
// Creates ./output/path/merged-module-module.html file
sc.combine('./file/path/module');

custom processors

custom.ts.processor.js

import { BaseTransformation } from '../../src/transform/base';
 
export class TypeScript extends BaseTransformation {
    constructor(tsService) {
        super('ts', true);
        this._tsService = tsService;
    }
 
    transform(content) {
        return `<script>${this._tsService.compile(content)}</script>`;
    }
}

usage

const fs = require('fs');
const TypeScript = require('custom.ts.processor');
const tsService = require('ts-service');
const { AnyFileMerge, Html, Js, Css } = require('any-file-merge');
const config = {
    output: './output',
    fileName: 'merged-[name].html',
    processors: [
        new Html(),
        new TypeScript(tsService),
        new Css()
    ]
};
const sc = new AnyFileMerge(fs, config);
// Creates ./output/path/merged-module-module.html file
sc.combine('./file/path/module');

Readme

Keywords

none

Package Sidebar

Install

npm i any-file-merge

Weekly Downloads

0

Version

1.0.3

License

MIT

Unpacked Size

153 kB

Total Files

26

Last publish

Collaborators

  • twz