Prathik Shetty
awebdeveloper
Convert Less/Sass to CSS
Convert TypeScript/Es6 to Es5 JS
Install dependencies
Run Linters
Run Test cases
Minify and Uglify your code
npm install -g grunt grunt-cli grunt-init
git clone https://github.com/gruntjs/grunt-init-gruntfile.git ~/.grunt-init/gruntfile
grunt-init gruntfile
# answer a few questions
npm install
grunt
# start the default task
module.exports = function (grunt) {
require('load-grunt-tasks')(grunt)
grunt.initConfig({
yeoman: {
src: 'src/',
dist: 'dist/'
},
less: {
main: {
expand: true,
cwd: '<%= yeoman.src %>',
src: ['*.less'],
dest: '<%= yeoman.dist %>',
ext: '.css'
}
}
})
grunt.registerTask('default', ['less'])
}
gruntfile.js
npm install --save-dev load-grunt-tasks grunt-contrib-less
grunt
No more pre-process (compile, compress, concat)
npm install -g gulp
npm init
npm install --save-dev gulp
mkdir PROJECT_NAME && cd PROJECT_NAME
touch gulpfile.js
const gulp = require('gulp'),
less = require('gulp-less')
gulp.task('less', function () {
return gulp
.src('/less/*.less')
.pipe(less({ compress: true }))
.pipe(gulp.dest('/css'))
});
gulp.task('default', ['less']);
gulpfile.js
npm install --save-dev gulp-less
gulp less
npm init
npm install --save-dev webpack
mkdir PROJECT_NAME && cd PROJECT_NAME
touch webpack.config.js
var path = require("path");
var Webpack = require("webpack");
// Our configuration
module.exports = {
// Define the entry point
entry: path.resolve(__dirname, "js", "app.js"),
// Output configuration
output: {
path: path.resolve(__dirname, "assets"),
filename: "budle.js"
},
module: {
loaders: [
// Inform about CSS loaders so that it can be bundled too
{ test: /\.css$/, loader: "style-loader!css-loader" }
]
},
// Generate source map files
devtool: "source-map"
};
webpack.config.js
webpack --config webpack.config.js
{
...
"scripts": {
"build": "webpack"
},
...
}
package.json
npm run build