GithubHelp home page GithubHelp logo

aneerdil / angular2gulp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kishoreithadi/angular2gulp

0.0 0.0 0.0 54 KB

Angular2 production build using gulp in multiple ways.

License: MIT License

JavaScript 51.73% HTML 26.70% TypeScript 20.23% CSS 1.34%

angular2gulp's Introduction

Angular2 Gulp Production Build

This application demonstrates how to give production build using gulp in multiple ways.

Download/Clone the project from the GitHub

npm install

Install gulp globally

npm install gulp -g

Description

This application demonstrates two kinds of builds

1. build-prod

npm run build-prod

After running the above command, the production build will be placed in dist folder.

In this build, all the HTML files included using templateUrl and CSS files included using styleUrls will be copied into production build folder(dist). The final build file structure is shown below. Here we have to maintain the same folder structure as in development.

Alt text

You can also combine all the component CSS files into a single bundle as shown in below gulp task.

gulp.task('bundle-component-css', () => {
    return gulp.src('src/app/**/*.css')
        .pipe(concat('bundlecss.css'))
        .pipe(rename({
            suffix: '.min'
        }))
        .pipe(cssMinify())
        .pipe(gulp.dest('dist/src/css/'))
});

2. build-prod-inline

npm run build-prod-inline

After running the above command, the production build will be placed in dist folder.

In this build, all the HTML pages included using templateUrl and CSS files included using styleUrls will be loaded into the JS file as templates. This way the application will load the HTML, CSS much faster and the total number of request made will be less. The final build file structure is shown below.

Alt text

Conclusion

It really depends on the developer to choose the appropriate build based on their requirement. In the first scenario, replacing the CSS and HTML in production server would be much easier. In the second scenario, you have to run the gulp task and then replace appropriate files.

angular2gulp's People

Contributors

kishoreithadi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.