GithubHelp home page GithubHelp logo

modjs-autoload-demo's Introduction

modjs-autoload-demo

modjs-autoload-demo基于modjs-todo-demo 调整而来,与modjs-todo-demo不同之处在于重点演示如何利用FIS自动管理同步、异步资源以及自动合并功能。

modjs-autoload-demo插件介绍

安装fis

npm install -g fis

安装成功后执行 fis -h 即可看到相关开发命令帮助

安装fis的扩展插件,这个项目用到的

npm install -g fis-postprocessor-require-async #可选
npm install -g fis-postpackager-autoload
npm install -g fis-postpackager-simple

让代码跑起来!

首先,启动内置的调试服务器:

fis server start

此时fis会启动一个精巧的jetty服务器,并且打开浏览器访问了 http://127.0.0.1:8080 ,现在这个调试环境什么也没有,接下来,我们在命令行下cd到我们下载的样例项目中:

cd modjs-autoload-demo

第三步,执行fis的编译命令:

fis release

第四步,刷新浏览器,查看我们的项目。

可以看到所有的模块化资源均已以标签的形式加载进来了

第五步,优化性能

虽然目前项目可以正常运行,但是这种加载方式会造成连接数过多,让我们调整配置,使用simple插件为我们合并资源

fis release -pf fis-conf-with-simple.js

再次浏览页面,我们可以发现原有的大量静态资源已经自动合并。

目录规范

任何 目录规范部署规范编译规范 都是可配置的(配置代码),这里只介绍内置的规范。

内置的规范包括:

  1. 扔在 modules 目录下的js、css、less、coffee文件都是模块化文件,会自动包装define,自己就不要写了。使用require.async或者require加载模块的时候id与文件的对应规则是这样的:
文件 引用id 举个例子
/modules/a.js a require.async('a');
/modules/b/b.js b require.async('b');
/modules/b/c.js b/c require.async('b/c');
1. 扔在 ``lib`` 目录下的文件不被认为是模块化的,请直接在页面上使用script或link标签引用。

modjs-autoload-demo's People

Contributors

hefangshi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

modjs-autoload-demo's Issues

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.