The de facto starter repo for building scalable apps with Angular, ES6, and Webpack
This repo serves as a minimal starter for those looking to get up-and-running with Angular and ES6, using Gulp and Webpack for the build process.This seed is not a Yeoman generator. It's a minimal starter with tasks for building the boilerplate. These are its features:
Check out the JSPM version--an alternative to Webpack as an ES6 build system.
If you're looking for a preliminary Angular 2 build, please use the angular2-webpack-starter.
NG6 uses NPM scripts, Gulp, and Webpack together for its build system. Yes, you don't need Gulp if you're using Webpack. This is true if your build system is only responsible for file manipulation. However, ours is not.
Webpack
handles all file-related concerns:
Babel
*.spec.js
files as wellGulp
is the orchestrator:
Check out the JSPM version--an alternative to Webpack as an ES6 build system.
We use a componentized approach with NG6. This will be the eventual standard (and particularly helpful, if usingAngular's new router) as well as a great way to ensure a tasteful transition to Angular 2, when the time is ripe.Everything--or mostly everything, as we'll explore (below)--is a component. A component is a self-containedconcern--may it be a feature or strictly-defined, ever-present element of the UI (such as a header, sidebar, orfooter). Also characteristic of a component is that it harnesses its own stylesheets, templates, controllers, routes,services, and specs. This encapsulation allows us the comfort of isolation and structural locality. Here's how itlooks:
client
⋅⋅app/
⋅⋅⋅⋅app.js * app entry file
⋅⋅⋅⋅app.html * app template
⋅⋅⋅⋅common/ * functionality pertinent to several components propagate into this directory
⋅⋅⋅⋅components/ * where components live
⋅⋅⋅⋅⋅⋅components.js * components entry file
⋅⋅⋅⋅⋅⋅home/ * home component
⋅⋅⋅⋅⋅⋅⋅⋅home.js * home entry file (routes, configurations, and declarations occur here)
⋅⋅⋅⋅⋅⋅⋅⋅home.component.js * home "directive"
⋅⋅⋅⋅⋅⋅⋅⋅home.controller.js * home controller
⋅⋅⋅⋅⋅⋅⋅⋅home.scss * home styles
⋅⋅⋅⋅⋅⋅⋅⋅home.html * home template
⋅⋅⋅⋅⋅⋅⋅⋅home.spec.js * home specs (for entry, component, and controller)
All tests are also written in ES6. We use Webpack to take care of the logistics of getting those files to run in the various browsers, just like with our client files. This is our testing stack:
To run tests, type npm test
in the terminal. Read more about testing below.
Tools needed to run this app:
node
and npm
fork
this repoclone
your forknpm install
to install dependenciesNG6 uses Gulp to build and launch the development environment. After you have installed all dependencies, you may run the app. Running npm start
will bundle the app with webpack
, launch a development server, and watch all files. The port will be displayed in the terminal.
Here's a list of available tasks:
npm run build
dist/bundle.js
. It also prepares index.html
to be used as application entry point, links assets and created dist version of our application.npm run serve
webpack-dev-server
, serving the client folder.npm run watch
serve
npm start
(which is the default task that runs when typing gulp
without providing an argument)
serve
.npm run component
To run the tests, run npm test
.
Karma
combined with Webpack runs all files matching *.spec.js
inside the app
folder. This allows us to keep test files local to the component--which keeps us in good faith with continuing to build our app modularly. The file spec.bundle.js
is the bundle file for all our spec files that Karma will run.
Be sure to define your *.spec.js
files within their corresponding component directory. You must name the spec file like so, [name].spec.js
. If you don't want to use the .spec.js
suffix, you must change the regex
in spec.bundle.js
to look for whatever file(s) you want.Mocha
is the testing suite and Chai
is the assertion library. If you would like to change this, see karma.conf.js
.
It's always easier to learn something if you have an examples. Here is a list of repos which based on this starter:
Following a consistent directory structure between components offers us the certainty of predictability. We can take advantage of this certainty by creating a gulp task to automate the "instantiation" of our components. The component boilerplate task generates this:
⋅⋅⋅⋅⋅⋅componentName/
⋅⋅⋅⋅⋅⋅⋅⋅componentName.js // entry file where all its dependencies load
⋅⋅⋅⋅⋅⋅⋅⋅componentName.component.js
⋅⋅⋅⋅⋅⋅⋅⋅componentName.controller.js
⋅⋅⋅⋅⋅⋅⋅⋅componentName.html
⋅⋅⋅⋅⋅⋅⋅⋅componentName.scss // scoped to affect only its own template
⋅⋅⋅⋅⋅⋅⋅⋅componentName.spec.js // contains passing demonstration tests
You may, of course, create these files manually, every time a new module is needed, but that gets quickly tedious.To generate a component, run npm run component -- --name componentName
.
The parameter following the --name
flag is the name of the component to be created. Ensure that it is unique or it will overwrite the preexisting identically-named component.
The component will be created, by default, inside client/app/components
. To change this, apply the --parent
flag, followed by a path relative to client/app/components/
.
For example, running npm run component -- --name signup --parent auth
will create a signup
component at client/app/components/auth/signup
.
Running npm run component -- --name footer --parent ../common
creates a footer
component at client/app/common/footer
.
Because the argument to --name
applies to the folder name and the actual component name, make sure to camelcase the component names.
Contact us, anytime, regarding anything about this project.
enjoy — PatrickJS
在之前的版本中滚动条位置是一个大问题,主要表现在 1. 使用快捷键或者手势前进/后退的时候,滚动条的位置经常是错乱的,所以只能每个页面都要重置一个滚动条的位置; 2. #anchor1 锚点位置无法定位 2017年10月开始解决这个问题,历时7个月终于在 6.1 beta1 中解决了。 解决方案就是增加了一个全新的特性 Scroll Position Restoration,滚回到之前的位置。 有
问题内容: 在Spring Boot中,模式上有一些jar 。所有这些罐子都不包含任何包装。它们有什么用? 在Maven POM中,添加了以下依赖项: org.springframework.boot:spring-boot-starter-web org.springframework.boot:spring-boot-starter-actuator org.springframework.b
问题内容: 这是我的 pom.xml 这条线引起问题。 项目构建错误:com.skm:MyApps:0.0.1-SNAPSHOT的不可解析的父POM:无法从https:/转移org.springframework.boot:spring- boot-starter-parent:pom:2.0.2.RELEASE /repo.maven.apache.org/maven2已缓存在本地存储库中,直到
问题内容: 我试图将@NotNull约束添加到我的Person对象中,但是我仍然可以@POST具有空电子邮件的新Person。我在MongoDB上使用Spring Boot Rest。 实体类: 存储库类: 应用类别: pom.xml 当我通过邮递员@POST一个新对象时,例如: 我仍然使用此有效负载创建: 问题答案: 我遇到了同样的问题,但是仅启用验证对我而言不起作用,这确实与JPA和Mongo
问题内容: 我试图在我的appsettings.json文件中写入连接字符串,并将其带入我的启动文件中,但我不断得到一个Value不能为null。参数名称:connectionString。我一直在使用各种示例,但似乎看不到带有ASP.NET 1.0 Core启动类的新设置。 Appsetting.json文件: 尝试Startup.cs的方法 问题答案: 首先, 与在Visual Studio中
主要内容:starter,spring-boot-starter-parent传统的 Spring 项目想要运行,不仅需要导入各种依赖,还要对各种 XML 配置文件进行配置,十分繁琐,但 Spring Boot 项目在创建完成后,即使不编写任何代码,不进行任何配置也能够直接运行,这都要归功于 Spring Boot 的 starter 机制。本节我们将对 stater 进行介绍。 starter Spring Boot 将日常企业应用研发中的各种场景都抽取出来,做成一个个的
主要内容:Spring Boot Web 快速开发,示例 Spring MVC 是 Spring 提供的一个基于 MVC 设计模式的轻量级 Web 开发框架,其本身就是 Spring 框架的一部分,可以与 Spring 无缝集成,性能方面具有先天的优越性,是当今业界最主流的 Web 开发框架之一。 Spring Boot 是在 Spring 的基础上创建一款开源框架,它提供了 spring-boot-starter-web(Web 场景启动器) 来为