Use Gulp to build Avalon-based mobile projects

Source: Internet
Author: User

This project is based on the requirements of my company project, may be applicable to many other projects.

Prepare the gulp environment.

First you can create a project using gulp, configure the Gulpfile.js file, I put gulpfile.js under the root directory

See here for specific configuration and installation command methods

My project directory

My project directory is like this:

==build//        Project build directory |        HTML//html file directory | Images      //Picture file directory | javascripts//javascript file directory | Libs     //JS Library File | stylesheets//Style file directory ==gulpfile.js

  


The AVALONJS used in the program can be
Over hereSee, at the same time s used theMmrouter The main files are as follows

When you see the following you will find a slideout.js file, this is our mobile side of the sidebar, I was to take someone else's code to use their own, see here

Main.html

The build directory

<! DOCTYPE html>

  

Avalon.mobile.min.js in the build directory

The main main.js

Under the Build/javascripts directory

require.config ({//config avalonjsbaseurl: ' javascripts ',//base path paths: { Avalon: '. /avalon.mobile.min.js '},shim: {avalon: {exports: ' Avalon '}},debug:false}); require ([' Avalon ', ' ready! ', ' libs/ Mmstate '], function (Avalon) {Console.log (Avalon);//define the top-level Vmavalon.define ({$id: ' main ', slideoutclose:function () { Slideout.close ();}}); /define various states, the internal will be converted to a routing table, to Mmrouter to handle avalon.state (' index ', {controller: ' main ', url: '/', Views: {': {templateurl: ' Templates/index.html '//templates under the index.html Fragment}},onbeforeenter:function () {require ([' index '], function (index) { Index.init ();});},onerror:function (err) {Avalon.log (err);}}); Avalon.state (' Test ', {controller: ' main ', url: '/test ', Views: {': {templateurl: ' templates/test.html '// Templates test.html Fragment}},onbeforeenter:function () {require ([' test '], function (test) {test.init ();});},onerror: function (Err) {Avalon.log (err);}}); /Start History Manager Avalon.history.start ({basepath: '/app '});//Start scanning Avalon.scan ();}); 

  


Path Build/templates
The following two paragraphs are HTML fragments

Index.html Fragment

<div ms-controller= "index" id= "index" >    <p ms-text= "TestName" ></p></div>

Test.html Fragment

<div ms-controller= "Test" >  <p ms-text= "TestName" ></p></div>

  

Libs file

The required JS files are delegated in Libs, including Mmstate, Mmhistory, Mmrouter, etc.

Finally, use the Gulp command to generate the assets directory reference

Https://github.com/gulpjs/gulp
Https://github.com/baixiaosh/avalon
Https://github.com/RubyLouvre/mmRouter
Https://github.com/baixiaosh/slideout

If there is anything wrong with this article, I hope the gods will point it out so as not to mislead other men, thank you.

This address: http://www.cnblogs.com/baixiaosheng/p/4390253.html

Use Gulp to build Avalon-based mobile projects

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.