RequireJS |
LMD |
Grunt |
Steal.js |
Brunch |
RequireJS
|
LMD |
Grunt |
Steal.js |
Brunch |
|
Steal
J S
|
project
jquery
steal
app
index.html
<script src="steal/steal.js"></script>
<script>steal('jquery/jquery.js')</script>
$ npm i grunt-cli -g
$ npm init
$ npm i grunt --save
project
node_modules
package.json
Gruntfile.js
index.html
{
"name": "frontend-project",
"version": "0.0.0",
"description": "My amazing front-end project",
"dependencies": {
"grunt": "~0.4.1",
},
"devDependencies": {}
}
steal('jquery/jquery.js')
.then(function($) {
//run you application here
});
<script src="steal/steal.js?app/app.js"></script>
<script src="steal/steal.js?app"></script>
$ npm i grunt-contrib-uglify --save-dev
module.exports = function(grunt) {
grunt.initConfig({
uglify: {
options: {
banner: '/* <%= grunt.template.today("yyyy-mm-dd") %> */\n'
},
myapp: {
src: 'app/app.js',
dest: 'build/app.min.js'
}
}
});
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.registerTask('default', ['uglify']);
};
<script src="build/app.min.js"></script>
$ grunt
$ grunt uglify
$ grunt uglify:build
project
jquery
steal
app
app.js
table
table.js
resources
less
views
scripts
index.html
steal(
'jquery/view/ejs',
{src: "steal/less", ignore: true}
).then(
//styles
'resources/less/table.less',
//templates
'resources/views/table.ejs',
'resources/views/cell.ejs',
//scripts
'resources/scripts/date.js'
).then(function($) {
window.Table = function() {...};
});
stea('jquery')
.then('app/table/table.js')
.then(function($) {
new window.Table(...);
});
watch: {
mysrc: {
files: ['**/*.js'],
tasks: ['uglify:dev'],
options: {
nospawn: true,
}
}
}
hub: {
all: {
src: ['app/table/Gruntfile.js'],
tasks: ['jshint', 'uglify'],
}
}
steal(
'jquery/view/ejs',
{src: "steal/less", ignore: true}
).then(
//styles
'resources/less/table.less',
//templates
'resources/views/table.ejs',
'resources/views/cell.ejs',
//scripts
'resources/scripts/date.js'
).then(function($) {
window.Table = function() {...
$(el).html($.View('resources/views/table.ejs'));
...};
});
jade: {
compile: {
options: {
compileDebug: false,
client: true,
namespace: 'App.Templates',
processName: function(filename) {
var basename = path.basename(filename, '.jade');
// table.jade --> App.Templates.Table
return basename.charAt(0).toUpperCase()
+ basename.slice(1);
}
},
files: { 'build/templates.js': 'app/table/views/*.jade' }
}
}
steal(
'jquery/view/ejs',
{src: "steal/less", ignore: true}
).then(
//styles
'resources/less/table.less',
//templates
'resources/views/table.ejs',
'resources/views/cell.ejs',
//scripts
'resources/scripts/date.js'
).then(function($) {
window.Table = function() {...};
});
//!steal-remove-start
code to be removed at build
//!steal-remove-end
steal({
src: "app/table/table.js",
type: "js",
packaged: false,
unique: true,
ignore: false,
waits: false
})
project
jquery
steal
app
build-scripts
( function( args ) {
load( "steal/rhino/rhino.js" );
new steal.File( "Build" ).mkdir();
steal.build("index.html", { to: "Build", all: true });
})();
> java -jar steal\rhino\js.jar -opt -1 app\build-scripts\build_app.js
grunt build
options.use.forEach(function (e) {
var fnName = e.shift();
var fnArgs = e.map(function (arg) {
return JSON.stringify(arg);
}).join(', ');
css.use(eval(fnName + '(' + fnArgs + ')'));
});