Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Create Modular Front-End Build System. Based on gulp, very easy and light
html/js/css/img/fonts/tpl
are in one same folder, like Baidu FIS
. Good concept for FE source management / development.gulp
. More simple, flexible, expandable and stable. Everyone know gulp can do secondary development.base64
image in html/CSS
JS/CSS
inlnied in htmlrequire('main.css')
, require css file in jsspritesmith
, support auto sprite imgicon-font
, support SVG 2 Iconfont.usemin
,support complex combo/package..tpl
file will packaged into js file,support async js loading.SCSS|ES6|ReactJS|Vuejs|Babel|Browserify|cssnano|uglify|imagmein
and other plugins,One-Stop Solution Service, very Simple and Stronggulp
plugins, you can use them in gulpman
. For example, you can put browser-sync
in your gulpman build systemkarma
framework,support babel/es6
unit test and coverage result.gulp
、gulp-sass
manuallynpm install gulpman --save-dev
gulp gm:install
to finish the setupcnpm
to install it: cnpm install gulpman --save-dev
If gulp-sass
install failed, please run cnpm install gulp-sass gulp-imagemin
by manual to fix that.
If error happened in npm install,such as /usr/local/lib/node_modules
permission error, fix this by sudo chown -R "$(whoami)"
+Path
sudo npm install
is not recommended
The imagemin-pngquant module needlibpng-devel
,if in Linux, please run yum install libpng-devel
at first
If install failed, check the npm-debug.log
to see if there are some ENOMEM
errors
Config
, and directly jump to Usage
gulpman
in your gulpfile.js,then it will load gm:publish
, gm:develop
into gulp tasks.gulp gm:publish
or gulp gm:develop
in terminal then it will work/**
* Gulpfile.js
*/
var gulp = require('gulp'),
gman = require('gulpman')
// your other tasks ...
// xxx ...
/**
* config gulpman ======================
* Use config API
* assets path, CDN, URL prefix
*/
gman.config({
// whether use absolute path, default `true`
'is_absolute': true,
// cdn prefix support[string|array|function]arguments
'cdn_prefix': '',
// url prefix, defautl `/static`. This involves the server config ,such as the static path of nginx
'url_prefix': '/static',
/** use spritesmith for css-img sprite
* Based on Spritesmith: https://github.com/Ensighten/spritesmith
* Automatecially generate Sprite Image & CSS
**/
//'spritesmith': { },
/** usemin config **/
// 'usemin': {}
// The COMPONENTS directory
'components': 'components',
// For development assets and templates folder, related to Server Config
'runtime_views': 'views',
'dist_views': 'views_dist',
// For production assets and templates folder, related to Server Config
'runtime_assets': 'assets',
'dist_assets': 'assets_dist',
// The js library dir, set as a global module. Also you can set as `bower_components`
'lib': 'lib',
// You can add one customer global directory, so you can require module name directly, like: `require ('xxx')`. The xxx is in this directory
'global': 'common'
})
cdn_prefix
support String, Array, FunctionmediaFile
'cdn_prefix': function (fileName) {
console.log(fileName)
var c_list = [
'http://s0.com',
'http://s1.com',
'http://s2.com',
'http://s3.com',
'http://s4.com'
]
// You can customized your strategy
if(hostFile.match(/\.html$/gm)){
return c_list[0]
}else {
return c_list[1]
}
},
is_absolute
is_absolute
is the dist path of source in html. default true. the dist path is like /static/home/main.js
[*]Need consistent config with Server, like nginx, apache
If no local server, you can set is_absolute as false, use relative path. Like ../../assets/static/home/main.js
Use gulpman to arrange your directory as component,The root component dir can be./components
(default). If you have one component named foo, then ./components/foo
,all related assets such as html|js|css|fonts|image
should be put in foo
folder.
This solution for assets can be high efficiency and easy to maintain.
gm:develop
to start develop
mode, the views
dir and assets
dir can be generated automatically
gm:publish
to publish assets in production env. The views_dist
and assets_dist
can generated.
For Browserify
packing, the js module in global dir
can be directly require
or import
in es6/js code
In gulpman.config
, the lib
和global
are global directory. Take an example:
components/lib
directory, you have one module foo.js
,then it is components/lib/foo.js
. So when you use foo in your es6 file, you can use it like: import foo from 'foo'
, no need write as import foo from '../lib/foo'
similarly, global
option can set your dir as global module dir. You can set bower
dir as your lib
dir.
Please make no conficts in your global dir
gulpman.config({
'is_absolute': false,
'components': 'components/cc',
'runtime_views': 'runtime_views/rv',
'dist_views': 'dist_views/dv/dv',
'dist_assets': 'dist_assets/da',
'runtime_assets': 'runtime_assets/ra/ra',
})
# Create components directory and add one demo
# init components dir and a html demo
gulp gm:init
# develop and watch mode,watchings files changes and update files
gulp gm:develop
# Build and Watch one special component, other files are not compiled
gulp gm:develop -c component_name1,component_name2,component_name3...
# publish assets in production env
gulp gm:publish
# publish command support `-a`和`-v` parameters to set output assets/views path.
gulp gm:publish -v your_views_dist -a your_assets_dist
# clean dist files
gulp gm:clean
# clean dist files, including subfolders
gulp gm:clean-deep
# Generate one developing assets/views files, but not in watching mode
# compile for develop, not watch
gulp gm:compile
When the project become huge, if we watch all components assets, it will be slow and low efficiency, so we can only watch special component to get better performance
Fox example, if we want watch the home
component:
# this will only build and watch `components/home` components
gulp gm:develop -c home
React
in gulpmannpm install react react-dom
import React from 'react';
import ReactDOM from 'react-dom';
// xxx
tpl
file in js|es6|jsxSupport .tpl
file, it will be packaged in dist js files.
Usage: import dialogTpl from './dialog.tpl'
or var dialogTpl = require('./dialog.tpl')
?_gm_inline
in assets src path in html/cssbase64
code will be inlined in html/css<p class="play">
<img width="480" alt="Karat 克拉" src="./img/testb64.png?_gm_inline" />
</p>
.test {
background: url(./img/testb64.png?_gm_inline) no-repeat;
}
?_gm_inline
in url path<script src="./plugin.js?_gm_inline" type="text/javascript"></script>
<link href="./dialog.css?_gm_inline" rel="stylesheet" type="text/css" >
gulpman.config({ enableCSSSprite: true })
, the default is false.?_gm_sprite
to img url.demo {
background: url(./img/abc.png?_gm_sprite) no-repeat;
/* other style you can set ...*/
width: 50px;
height: 50px;
}
js
|css
|inlinejs
|inlinecss
syntax
<!-- build:css ./home.css -->
<link rel="stylesheet" type="text/css" href="./main.css">
<link rel="stylesheet" type="text/css" href="./fff.css">
<!-- endbuild -->
<!-- build:js ../lib/base_lib.js -->
<script type="text/javascript" src="../lib/jquery.js"></script>
<script type="text/javascript" src="../lib/react.js"></script>
<!-- endbuild -->
.tpl
files in your component, and use require
or import
in ES6, then the tpl files will be packaged in js files. import dialogTpl from './dialog.tpl'
var dialogTpl = require('./dialog.tpl')
import from './style.css';
require('./style.css');
@font-face
in cssgulp gm:iconfont:install
before first runningcomponents/iconfonts/source
directory, then run gulp gm:iconfont
to begin start converticonfonts/gmicon
folderrelative path
$LAB.script("../testload/test.js").wait(()=>{console.log('test loaded')})
require('./style.css')
or import style from './style.css'
gulp gm:karma:install
before first running, it will install dependencies and generate karma.conf.js
.spec
, then put your spec es6 files in the spec
folder, the file extname must be .es6
gulp gm:karma:start
in CLI to start Karma Unit Test, you can view the coverage result in coverage
foloderkarma.conf.js
MIT
FAQs
Create Modular Front-End Build System. Based on gulp, very easy and light
We found that gulpman demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.