A simple and well structured boilerplate project based on AngularJS and Zurb's Foundation
npm install -g grunt-cli bower
npm install -g karma
npm install -g phantomjs
npm install -g protractor
webdriver-manager update
(installs the Chrome driver by default)npm install -g serve
(for local web testing)NOTE: If you have previous versions of any of the above packages, it's recommended that you update them: npm update -g
git clone https://github.com/cmacdonnacha/angularjs-foundation-boilerplate.git myApp
cd myApp
npm install
- this installs both the required NodeJS modules and the bower component libraries.IMPORTANT: If you run into any issues please have a look at the "Troubleshooting" section at the bottom of this page.
grunt watch
: Creates a development build folder called 'public' and serves it on: http://localhost:9000/
grunt test
: Runs code checks, unit tests and E2E testsgrunt run:unit
: Runs unit tests onlygrunt run:e2e
: Runs E2E tests onlygrunt production
: Creates a production build in a folder called 'production'grunt run:production
: Serves the 'production' build on: http://localhost:9000/
if it exists.grunt eslint
: Runs an ESLint code checkgrunt reports
: will create and serve the 'reports' folderhttp://localhost:22000/
This project follows a "Folders-by-Feature" structure very similar to John Papa's Styleguide. From the folder structure below you can see that there are 6 separate components, a folder for each one. Each component is treated as a mini Angular app. This structure allows us developers to easily locate code and identify what each file represents at a glance. By retaining this structure the project is much more manageable as it grows.
The app
folder contains the individual components:
about
: Contains the about page related files.common
: Contains all common services, directives etc. used across the entire app.home
: Contains the home page related files.layout
: Acts as a container for other layout components (about, home, topbar etc.)sample
: A template component that can be duplicated whenever you want to create your own component (Copy and paste).topbar
: Contains the topbar related files.Each component has its own sub-folder containing files associated with that component:
Note: Not every component will contain all of these sub-folders, just add them as you need them.
The assets
folder contains the globally used fonts and images.
The styles
folder contains all of the global sass files needed to style the app. Let's have a closer look at each file:
_font-awesome.scss
: Contains all of the font awesome icons taken from the vendor/font-awesome
folder. Check this out to see all available icons._mixins.scss
: This is where you can put your very own Sass Mixins that can be used globally throughout the app. This should only contain Mixins._settings.scss
: Allows you to override the default Foundation styles with your own. This is detailed in a section below._shared.scss
: This is where you can put your very own Sass that can be used globally throughout the app. Typically it's where you would add globally used Sass classes which would then use mixins from the _mixins.scss
file.main.scss
: Brings everything together. Contains all of the Sass file imports. It's what tells the app where to grab the styles from.As you can see in this boilerpate project we have 6 sample components: about
, common
, home
, layout
, sample
and topbar
. Check out the wiki to see how you can go about adding your very own component.
Foundation is great because it comes with basic styling, leaving it up to you to give it your very own touch. You can do this by changing the _settings.scss
file inside the styles
folder:
Simply uncomment any of the sections in the _settings.scss
file and you will override the default Foundation styling. Don't like the color of the topbar? No problem, change to a nice bright pink instead. Find out more here.
Even crème de menthe projects have their issues. Here are some problems you may face along with some suggestions on how to resolve them:
npm install
: "Error: EPERM or operation not permitted or permission denied"This error means that NPM was not able to install one of the node modules to the file system. There are three major reasons why this could happen:
Suggestion:
npm cache clean
.npm install
again.npm install
: "Error: Can't find Python executable 'python', you can set the PYTHON env variable."Suggestion: This error can be ignored (it's a warning really) as the node modules will install successfully anyway. The reason this error appears is because
some node modules have dependencies on a clunky build tool called node-gyp
that compiles C++ extensions for NodeJS, and it requires python. Long story short,
if you don't have Python installed on your machine you will see these errors but it's nothing to worry about.
grunt production
task.Suggestion: Make sure you have administrator permissions to delete folders from the directory. If you're still seeing the issue then manually delete the production
folder and run grunt production
again.
grunt test
task: "No selenium server jar found at the specified location"Suggestion: Run the following command and try again: webdriver-manager update
grunt test
task.Suggestion: Make sure you have Java installed. Close and re-launch the command line and try again.
Suggestion: Run the following command: npm install stylus -g
grunt watch
task: "Error: 'libsass' bindings" not found. Try reinstalling 'node-sass'Suggestion: Run the following command: npm install grunt-sass
npm install
Suggestion:
Set Git global options to fetch components over 'https' instead of 'git' by running the following command:
git config --global url."https://".insteadOf git://
Suggestion 1:
grunt watch
task.grunt clean
grunt watch
again.Suggestion 2:
This project has been tested with the following tools:
If you are running into issues while installing node packages then ensure you have the versions above installed.
Believe it or not, angularjs-foundation-boilerplate is not perfect. If you want to improve it somehow then by all means go ahead and create a pull request :-)
06/11/2015
30/10/2015