Top Related Projects
CLI tool for Angular
A bundler for javascript and friends. Packs many modules into a few bundled assets. Code Splitting allows for loading parts of the application on demand. Through "loaders", modules can be CommonJs, AMD, ES6 modules, CSS, Images, JSON, Coffeescript, LESS, ... and your custom stuff.
Deliver web apps with confidence 🚀
MFE Starter
🌱 [Deprecated] Extensible, reliable, modular, PWA ready starter project for Angular (2 and beyond) with statically typed build and AoT compilation
Yeoman generator for an Angular app with an Express server
Quick Overview
The preboot/angular-webpack repository is a starter kit for Angular applications using Webpack as the build tool. It provides a pre-configured setup for developing Angular projects with Webpack, including hot module replacement and production-ready optimizations.
Pros
- Streamlined setup process for Angular projects with Webpack
- Includes hot module replacement for faster development
- Optimized production build configuration
- Integrates TypeScript support out of the box
Cons
- May require additional configuration for complex project structures
- Some users might find the setup overwhelming if they're new to Webpack
- Limited documentation and examples provided in the repository
- Might not be up-to-date with the latest Angular and Webpack versions
Code Examples
- Basic component example:
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
template: '<h1>Hello, {{ title }}!</h1>'
})
export class AppComponent {
title = 'Angular Webpack Starter';
}
- Webpack configuration snippet:
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: './src/main.ts',
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].[hash].js'
},
plugins: [
new HtmlWebpackPlugin({
template: './src/index.html'
}),
new webpack.HotModuleReplacementPlugin()
]
};
- Angular module example:
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
@NgModule({
imports: [BrowserModule],
declarations: [AppComponent],
bootstrap: [AppComponent]
})
export class AppModule { }
Getting Started
-
Clone the repository:
git clone https://github.com/preboot/angular-webpack.git cd angular-webpack
-
Install dependencies:
npm install
-
Start the development server:
npm start
-
Build for production:
npm run build
The application will be available at http://localhost:8080
during development.
Competitor Comparisons
CLI tool for Angular
Pros of Angular CLI
- Official Angular tool with extensive documentation and community support
- Provides a complete development environment with built-in testing, linting, and production builds
- Offers easy scaffolding for components, services, and other Angular artifacts
Cons of Angular CLI
- Less flexible configuration options compared to custom Webpack setups
- Potentially steeper learning curve for developers new to Angular ecosystem
- May include unnecessary dependencies for simpler projects
Code Comparison
Angular CLI (angular.json):
{
"projects": {
"my-app": {
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/my-app",
"index": "src/index.html",
"main": "src/main.ts"
}
}
}
}
}
}
Angular Webpack (webpack.config.js):
module.exports = {
entry: './src/main.ts',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js'
},
module: {
rules: [
{ test: /\.ts$/, loader: 'ts-loader' }
]
}
};
The Angular CLI configuration is more declarative and abstracted, while the Angular Webpack setup offers more direct control over the build process. Angular CLI provides a more opinionated structure, whereas Angular Webpack allows for greater customization but requires more manual configuration.
A bundler for javascript and friends. Packs many modules into a few bundled assets. Code Splitting allows for loading parts of the application on demand. Through "loaders", modules can be CommonJs, AMD, ES6 modules, CSS, Images, JSON, Coffeescript, LESS, ... and your custom stuff.
Pros of webpack
- More versatile and can be used with various frameworks, not limited to Angular
- Larger community and more frequent updates
- Extensive plugin ecosystem for additional functionality
Cons of webpack
- Steeper learning curve, especially for beginners
- More complex configuration required for advanced use cases
- May require additional setup for Angular-specific features
Code Comparison
angular-webpack:
module.exports = {
entry: './src/app.ts',
output: {
filename: 'bundle.js'
},
module: {
rules: [
{ test: /\.ts$/, loader: 'ts-loader' }
]
}
};
webpack:
module.exports = {
entry: './src/index.js',
output: {
filename: 'main.js',
path: path.resolve(__dirname, 'dist')
},
module: {
rules: [
{ test: /\.js$/, exclude: /node_modules/, use: 'babel-loader' }
]
}
};
The code comparison shows that both configurations are similar, but webpack's example is more generic and not specifically tailored for Angular. angular-webpack focuses on TypeScript compilation, while the webpack example includes Babel for JavaScript transpilation.
Deliver web apps with confidence 🚀
Pros of Angular
- Official framework maintained by Google, ensuring long-term support and regular updates
- Comprehensive ecosystem with built-in tools, CLI, and extensive documentation
- Integrated dependency injection system for better modularity and testability
Cons of Angular
- Steeper learning curve due to its comprehensive nature and TypeScript requirement
- Larger bundle size, which may impact initial load times for applications
- More opinionated structure, potentially limiting flexibility for some developers
Code Comparison
Angular:
@Component({
selector: 'app-root',
template: '<h1>{{title}}</h1>'
})
export class AppComponent {
title = 'Angular App';
}
Angular-Webpack:
angular.module('app', [])
.component('appRoot', {
template: '<h1>{{$ctrl.title}}</h1>',
controller: function() {
this.title = 'Angular-Webpack App';
}
});
Key Differences
- Angular uses TypeScript and decorators, while Angular-Webpack uses JavaScript and traditional Angular 1.x syntax
- Angular has a component-based architecture, whereas Angular-Webpack follows the older module-based approach
- Angular provides a more structured and opinionated framework, while Angular-Webpack offers more flexibility in configuration
Conclusion
Angular is a modern, full-featured framework suitable for large-scale applications, while Angular-Webpack is a lightweight solution for integrating Angular 1.x with Webpack. The choice between them depends on project requirements, team expertise, and desired level of control over the build process.
MFE Starter
Pros of PatrickJS-starter
- More comprehensive and feature-rich starter kit
- Includes additional tools like TypeScript and RxJS
- Regularly updated with the latest Angular and webpack versions
Cons of PatrickJS-starter
- Steeper learning curve due to additional complexity
- Potentially overkill for smaller projects
- May require more configuration and setup time
Code Comparison
PatrickJS-starter:
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
@NgModule({
imports: [BrowserModule],
declarations: [AppComponent],
bootstrap: [AppComponent]
})
export class AppModule { }
angular-webpack:
import angular from 'angular';
import AppComponent from './app.component';
angular.module('app', [])
.component('app', AppComponent);
Key Differences
- PatrickJS-starter uses Angular's newer TypeScript-based architecture
- angular-webpack relies on the older AngularJS (1.x) framework
- PatrickJS-starter includes more modern development practices and tooling
- angular-webpack is simpler and may be easier for beginners to understand
Both repositories aim to provide a starting point for Angular development with webpack, but they cater to different versions of Angular and varying levels of project complexity.
🌱 [Deprecated] Extensible, reliable, modular, PWA ready starter project for Angular (2 and beyond) with statically typed build and AoT compilation
Pros of angular-seed
- More comprehensive and feature-rich, offering a complete development environment
- Includes testing setup with Karma and Jasmine out of the box
- Provides a modular structure for better code organization and scalability
Cons of angular-seed
- Steeper learning curve due to its complexity and extensive features
- May be overkill for smaller projects or those requiring a simpler setup
- Slightly slower build times compared to angular-webpack due to additional features
Code Comparison
angular-seed:
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
@NgModule({
imports: [BrowserModule],
declarations: [AppComponent],
bootstrap: [AppComponent]
})
export class AppModule { }
angular-webpack:
import angular from 'angular';
import AppComponent from './app.component';
angular.module('app', [])
.component('app', AppComponent);
The code comparison shows that angular-seed uses Angular's more recent TypeScript-based approach, while angular-webpack uses the older AngularJS syntax. This reflects the different focuses of the two projects, with angular-seed being more up-to-date and comprehensive, while angular-webpack provides a simpler, webpack-centric setup for AngularJS projects.
Yeoman generator for an Angular app with an Express server
Pros of generator-angular-fullstack
- Full-stack solution with both frontend and backend scaffolding
- Includes authentication and user management out of the box
- Offers a wider range of development tools and features
Cons of generator-angular-fullstack
- More complex setup and configuration process
- Potentially steeper learning curve for beginners
- Less flexibility for customizing the build process
Code Comparison
generator-angular-fullstack:
// Example of server-side route in generator-angular-fullstack
'use strict';
var express = require('express');
var controller = require('./thing.controller');
var router = express.Router();
router.get('/', controller.index);
angular-webpack:
// Example of webpack configuration in angular-webpack
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: './src/app.ts',
output: { path: 'dist', filename: 'app.bundle.js' },
module: { loaders: [ /* ... */ ] },
plugins: [ new HtmlWebpackPlugin({ template: './src/index.html' }) ]
};
The code comparison highlights the different focus areas of the two projects. generator-angular-fullstack provides server-side routing and controller setup, while angular-webpack concentrates on frontend build configuration using Webpack.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
angular-webpack
A complete, yet simple, starter for Angular v2+ using Webpack.
This seed repo serves as an Angular starter for anyone looking to get up and running with Angular and TypeScript fast. Using Webpack for building our files and assisting with boilerplate. We're also using Protractor for our end-to-end story and Karma for our unit tests.
- Best practices in file and application organization for Angular.
- Ready to go build system using Webpack for working with TypeScript.
- Testing Angular code with Jasmine and Karma.
- Coverage with Istanbul
- End-to-end Angular code using Protractor.
- Stylesheets with SASS (not required, it supports regular css too).
- Error reported with TSLint and Codelyzer.
- Documentation with TypeDoc.
Warning: Make sure you're using the latest version of Node.js and NPM
Quick start
# clone our repo
$ git clone https://github.com/preboot/angular-webpack.git my-app
# change directory to your app
$ cd my-app
# install the dependencies with npm
$ npm install
# start the server
$ npm start
go to http://localhost:8080 in your browser.
Table of Contents
Getting Started
Dependencies
What you need to run this app:
node
andnpm
(Use NVM)- Ensure you're running Node (
v6.x.x
+) and NPM (3.x.x
+)
Installing
fork
this repoclone
your forknpm install
to install all dependencies
Developing
After you have installed all dependencies you can now start developing with:
npm start
It will start a local server using webpack-dev-server
which will watch, build (in-memory), and reload for you. The application can be checked at http://localhost:8080
.
As an alternative, you can work using Hot Module Replacement (HMR):
npm run start:hmr
And you are all set! You can now modify your components on the fly without having to reload the entire page.
Testing
1. Unit Tests
- single run:
npm test
- live mode (TDD style):
npm run test-watch
2. End-to-End Tests (aka. e2e, integration)
- single run:
- in a tab, if not already running!:
npm start
- in a new tab:
npm run webdriver-start
- in another new tab:
npm run e2e
- in a tab, if not already running!:
- interactive mode:
- instead of the last command above, you can run:
npm run e2e-live
- when debugging or first writing test suites, you may find it helpful to try out Protractor commands without starting up the entire test suite. You can do this with the element explorer.
- you can learn more about Protractor Interactive Mode here
- instead of the last command above, you can run:
Production
To build your application, run:
npm run build
You can now go to /dist
and deploy that to your server!
Documentation
You can generate api docs (using TypeDoc) for your code with the following:
npm run docs
FAQ
Do I need to add script / link tags into index.html ?
No, Webpack will add all the needed Javascript bundles as script tags and all the CSS files as link tags. The advantage is that you don't need to modify the index.html every time you build your solution to update the hashes.
How to include external angular libraries ?
It's simple, just install the lib via npm and import it in your code when you need it. Don't forget that you need to configure some external libs in the bootstrap of your application.
How to include external css files such as bootstrap.css ?
Just install the lib and import the css files in vendor.ts. For example this is how to do it with bootstrap:
npm install bootstrap@next --save
And in vendor.ts add the following:
import 'bootstrap/dist/css/bootstrap.css';
TypeScript
To take full advantage of TypeScript with autocomplete you would have to use an editor with the correct TypeScript plugins.
Use a TypeScript-aware editor
We have good experience using these editors:
- Visual Studio Code
- Webstorm 11+
- Atom with TypeScript plugin
- Sublime Text with Typescript-Sublime-Plugin
License
Top Related Projects
CLI tool for Angular
A bundler for javascript and friends. Packs many modules into a few bundled assets. Code Splitting allows for loading parts of the application on demand. Through "loaders", modules can be CommonJs, AMD, ES6 modules, CSS, Images, JSON, Coffeescript, LESS, ... and your custom stuff.
Deliver web apps with confidence 🚀
MFE Starter
🌱 [Deprecated] Extensible, reliable, modular, PWA ready starter project for Angular (2 and beyond) with statically typed build and AoT compilation
Yeoman generator for an Angular app with an Express server
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot