GithubHelp home page GithubHelp logo

egg-manifest's Introduction

egg-manifest

前后端使用 manifest.json 文件进行关联。

manifest.json 可以使用 webpack-manifest-plugin 插件生成。

Install

$ npm i egg-manifest --save

Usage

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

Configuration

一个后端关联一个前端

// {app_root}/config/config.default.js
exports.manifest = {
    default: path.join(appInfo.baseDir, '/public/prd/manifest.json'),
};

一个后端关联多个前端

// {app_root}/config/config.default.js
exports.manifest = {
    project1: path.join(appInfo.baseDir, '/public/prd1/manifest.json'),
    project2: path.join(appInfo.baseDir, '/public/prd2/manifest.json'),
    default: path.join(appInfo.baseDir, '/public/prd/manifest.json'),
};

注意。至少包含一个 default 配置

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

Example(在 view 中使用)

<script src="<%- ctx.loadManifest('vendor.js') %>"></script>

或者

<script src="<%- ctx.loadManifest('project1', 'star-home.js') %>.js"></script>

第一个参数依赖配置的 key ,比如上面 project1 项目,会去这个路径下的 manifest.json 文件中查找 lib.js。

manifest.json 样例

{
  "star-home.js": "http://localhost:7011/public/prd/[email protected]",
  "star-home.css": "http://localhost:7011/public/prd/[email protected]",
  "vendor.js": "http://localhost:7011/public/prd/[email protected]"
}

Questions & Suggestions

Please open an issue here.

License

MIT

egg-manifest's People

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.