1.0.5 • Published 6 years ago

egg-onefile2 v1.0.5

Weekly downloads
7
License
MIT
Repository
github
Last release
6 years ago

egg-onefile

NPM version build status Test coverage David deps Known Vulnerabilities npm download

This plugin will serve for dynamic file output.

Install

$ npm i egg-onefile2 --save

Usage

// {app_root}/config/plugin.js
exports.onefile = {
  enable: true,
  package: 'egg-onefile2',
};

Configuration

// {app_root}/config/config.default.js
exports.onefile = {
  match(ctx) {
    return ctx.url === '/';
  },
  headers: {
    'Content-Type': 'text/html; charset=utf-8',
    'Cache-Control': 'no-store',
  },
  replace: {
    '${hello}': 'hello',
  },
  * before() {
    // you can do something before
  }
  path: path.join(__dirname, '../app/public/index.html'),
};

see config/config.default.js for more detail.

Example

Questions & Suggestions

Please open an issue here.

License

MIT