标签:下载 doc from 文件夹 running color def package day
?
/*! * mymongolib * Copyright(c) 2009-2013 Blabla * MIT Licensed */ ? ‘use strict‘; ? module.exports = require(‘./lib/mymongolib‘); ? |
‘use strict‘ ? function MyMonboLib(connStr) { this.ConnStr = connStr; ? this.TestConn = function() { return true; } ? this.DeleteOneDoc(collName, _id) { return true; } ? } ? module.exports = MyMongoLib; |
?
module.exports = function(grunt) { ? // Project configuration. grunt.initConfig({ pkg: grunt.file.readJSON(‘package.json‘), uglify: { options: { banner: ‘/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n‘ }, build: { src: [‘lib/<%= pkg.name %>.js‘], dest: ‘dist/<%= pkg.name %>.js‘ } } }); ? // Load the plugin that provides the "uglify" task. grunt.loadNpmTasks(‘grunt-contrib-uglify‘); ? // Default task(s). grunt.registerTask(‘default‘, [‘uglify‘]); ? }; |
?
npm install grunt --save-dev |
?
npm install grunt-contrib-uglify --save-dev |
?
grunt |
?
结果如下:
Running "uglify:build" (uglify) task >> 1 file created 265 B → 193 B |
?
此时看到项目的根目录下,自动创建了一个dist文件夹,里面自动创建了一个mymongolib.js文件, 文件内容如下:
/*! mymongolib 2017-11-07 */ ? "use strict";function MyMonboLib(n){return this.ConnStr=n,this.TestConn=function(){return!0},this.DeleteOneDoc(collName,_id),!0}module.exports=MyMongoLib; |
?
大功告成!
?
?
?
当然,如果只想对一个js文件执行grunt操作,就不需要创建index.js和lib文件夹里面的文件,直接将文件放在根目录,然后将GruntFile.js文件中的路径改一下就好了。
?
如何创建一个 示例 GruntFile.
npm install -g grunt-cli |
?
git clone https://github.com/gruntjs/grunt-init-gruntfile.git ~/.grunt-init/gruntfile |
?
|
?
这个命令会给出提示:
Please answer the following: [?] Is the DOM involved in ANY way? (Y/n) n [?] Will files be concatenated or minified? (Y/n) y [?] Will you have a package.json file? (Y/n) y [?] Do you need to make any changes to the above before continuing? (y/N) n ? Writing Gruntfile.js...OK Writing package.json...OK ? Initialized from template "gruntfile". |
?
这样,在文件夹中就有了对应的GruntFile.js和package.json文件,可以用来做样例或者从中复制粘贴一些代码用。
标签:下载 doc from 文件夹 running color def package day
原文地址:http://www.cnblogs.com/time-is-life/p/7798325.html