npm.io
1.2.2 • Published 6 years ago

service-gen-loader

Licence
MIT
Version
1.2.2
Deps
0
Size
7 kB
Vulns
0
Weekly
0
Stars
2

Getting Started

install

$ yarn add service-gen-loader -D

service-mapping.json

import mapping from './service-mapping.json';

Then add the loader to your webpack config. For example:

webpack.config.js

module.exports = {
    module: {
        rules: [
            {
                test: /-mapping.json$/,
                use: [
                    {
                        loader: 'service-gen-loader',
                        options: {
                            fileName: 'service.js',
                            declareFileName: 'service.d.ts',
                            filePath: (ctx) => {
                                return ctx.context;
                            },
                            declareFilePath: (ctx) => {
                                return path.resolve(ctx.context, '../types');
                            }
                        }
                    }
                ]
            }
        ]
    }
}

Keywords