1.1.7 • Published 8 years ago

fis-pack v1.1.7

Weekly downloads
19
License
ISC
Repository
github
Last release
8 years ago

fis-pack

yog2/fis plugin for pack page and compatible well

Features

  • Compatible with the yog2/fis
  • Noninvasive pack the page js and css in one
  • Can cross yog2 app

Install

npm install fis-pack -g

How to Use

Import the module

var fisPack = fis.require('pack');

Set project name as a param

fis.config.set('projectName','yog');

Prepare the param

var entry = {
    "pkg/pio_demo.css": [
        "**/demo.tpl:deps"
    ],
    "pkg/pio_demo.js": [
        "**/demo.tpl:deps"
    ],
    "pkg/pio_test.css": [
        "**/test.tpl:deps"
    ],
    "pkg/pio_test.js": [
        "**/test.tpl:deps"
    ]
}

Use the plugin in the postpackager stage

//clone the original ret
var retClone = JSON.parse(JSON.stringify(ret));

for (var i in etrys) {
    if (JSON.stringify(etrys[i]).indexOf('.css"') !== -1) {
        realRet = fisPack(retClone, settings, etrys[i], opt);
    } else {
        realRet = fisPack(retClone, settings, etrys[i], opt, false);
    }
}
//if use the other app component in yog2 project,need remove the map not in the current app
for (var key in realRet.map.res) {
    if (key.indexOf(fis.get('namespace') + ':') === -1) {
        delete realRet.map.res[key];
    }
}

//get app map info
function getMap() {
    var path = require('path');
    var root = fis.project.getProjectPath();
    var map = fis.file.wrap(path.join(root, fis.get('namespace') + '-map.json'));
    return map;
}

var map = getMap();
//save the app map to the release dir
fs.writeFileSync('../'+fis.get('projectName')+'/' + map.release, JSON.stringify(realRet.map));

The result

github

Pack before

github

Pack after

github

1.1.7

8 years ago

1.1.6

8 years ago

1.1.5

8 years ago

1.1.4

8 years ago

1.1.3

8 years ago

1.1.2

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.9

8 years ago

1.0.8

8 years ago

1.0.7

8 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago