Skip to content

proprogrammer2015/any-file-merge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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');

About

Merge any set of files.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published