npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

grunt-seajs-pack

v0.1.2

Published

提取seajs依赖,生成id

Downloads

3

Readme

grunt-seajs-pack

从seajs模块中提取依赖,并根据当前路径生成id,基于[email protected]修改,去掉了配置参数, 只根据去掉所有配置参数,根据路径生成id

只支持html模板和js,html模板采用ejs,同时支持模版间依赖,如有以下文件:

  • views/file/main.js
  • views/file/main.html
  • models/file_m.js
  • tpls/layout.html

其中main.js为

    define(function(require,exp,mod){
        var model=require('models/file_m.js');
        var Tpl=require('./main.html');
    });

main.html如下,引用了tpls/layout.html

<script type="text/template" data-tpl="fileBox" data-fn="true">
<% var layout=seajs.require('tpls/layout.html'); %>
<%=layout.header%>
<section>file.html自己的内容</section>
<%=layout.footer({content:'这是底部'})%>
</script>

layout.html如下,其中header没有属性data-fn,只作为字串使用,不进行模板预编译footer含data-fn,将会进行模板预编译,见main.html中两者的使用方法

<script type="text/template" data-tpl="header">
    <header>头部</header>
</script>
<script type="text/template" data-tpl="footer" data-fn="true">
    <footer><%=content%></footer>
</script>

经提取后main.js如下,依赖会进行深度分析,html也会进行深度分析

   define('views/file/main.js',['models/file_m.js','tpls/layout.html','views/file/main.html'],function(require,exp,mod){
        var model=require('models/file_m.js');
        var Tpl=require('./main.html');
   });

经提取后main.html如下

   define('views/file/main.html',['tpls/layout.html'],function(require,exp,mod){
        var model=require('models/file_m.js');
        var Tpl=require('./main.html');
        return {
            fileBox:function(){.......}
        }
   });

经提取后layout.html如下

   define('tpls/layout.html',[],function(require,exp,mod){
        var tpls={
            header:'<header>头部</header>'
        };
        var fns={
            footer:function(obj){.....}
        };
        return _.extend(tpls,fns);
   });

使用方法

     grunt.loadNpmTasks('grunt-seajs-pack');
     grunt.initConfig({
         seajspack : {
             seajs:{
                 options:{
                     //idleading:''
                 },
                 files:[{
                     expand:true,
                     src:[
                         'views/**/*.*',
                         'pages/**/*.*',
                         'models/**/*.*',
                         'tpl/**/*.*'
                     ],
                     dest:'dist/cacheSeajs/'
                 }]
             }
         }
     });