Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplified version #28

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ node_modules
.DS_Store
.idea
Iconr
build
19 changes: 19 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
language: node_js
dist: trusty
sudo: required
node_js:
- 'node'

install:
- npm install

script:
- npm run build

deploy:
provider: pages
skip_cleanup: true
local_dir: build/prod/
github_token: $GITHUB_TOKEN
on:
branch: master
46 changes: 29 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,34 @@
# Three.js Webpack ES6 Boilerplate
https://github.com/paulmg/ThreeJS-Webpack-ES6-Boilerplate/

A basic boilerplate for a Three.js project including the use of Webpack and ES6 syntax via Babel.
This is a simplified fork of [Three.js Webpack ES6 Boilerplate](https://github.com/paulmg/ThreeJS-Webpack-ES6-Boilerplate/), a basic boilerplate for a Three.js project including the use of Webpack and ES6 syntax via Babel.

All auto-built files are removed from Git and generated at build time to clean and simplify the folder structures.

A Travis YML configuration is also provided to auto-deploy the static built production site via Github Pages and requires the additional configuration:

- Create a Personal Access Token with just ```repo``` access in [Github developer settings](https://github.com/settings/tokens)
- Create an Environmental Variable called ```GITHUB_TOKEN``` on your repo page on the [Travis website](https://travis-ci.com/)
- Create a new branch ```gh-pages``` and point GitHub Pages there on your repo's settings on Github.
- If you are using a custom domain, add a file named ```CNAME``` (no extension) to the root of the build folder containing just the URL

Travis will then auto-deploy the latest static production build via Github Pages on each new commit.

## Project Structure
```
build - Directory for built and compressed files from the npm build script
src - Directory for all dev files
├── css - Contains all SCSS files, that are compiled to `src/public/css`
├── js - All the Three.js app files, with `app.js` as entry point. Compiled to `src/public/js` with webpack
│ ├── app
│ │ ├── components - Three.js components that get initialized in `main.js`
│ │ ├── helpers - Classes that provide ideas on how to set up and work with defaults
│ │ ├── managers - Manage complex tasks such as GUI or input
│ │ └── model - Classes that set up the model object
│ ├── data - Any data to be imported into app
│ └── utils - Various helpers and vendor classes
└── public - Used by webpack-dev-server to serve content. Webpack builds local dev files here.
└── assets - Is copied over to build folder with build command. Place external asset files here.
──build - Directory for all built files (excluded from Git)
├── dev - Webpack builds local dev site here. Used by webpack-dev-server to serve content locally during development.
├── prod - Webpack builds static production site here. Use for serving the static site on a webserver.
──src - Directory for all source files
├── assets - Is copied over to build folder with build command. Place external asset & vendor files here.
├── css - Contains all SCSS files, that are compiled to `src/public/css`
├── js - All the Three.js app files, with `app.js` as entry point. Compiled to `src/public/js` with webpack
│ ├── app
│ │ ├── components - Three.js components that get initialized in `main.js`
│ │ ├── helpers - Classes that provide ideas on how to set up and work with defaults
│ │ ├── managers - Manage complex tasks such as GUI or input
│ │ └── model - Classes that set up the model object
│ ├── data - Any data to be imported into app
│ └── utils - Various helpers and vendor classes
```

## Getting started
Expand All @@ -40,7 +51,7 @@ Spins up a webpack dev server at localhost:8080 and keeps track of all js and sa
npm run build
```

Cleans existing build folder while linting js folder and copies over the public assets folder from src. Then sets environment to production and compiles js and css into build.
Cleans existing build/prod folder while linting js folder and copies over the public assets folder from src. Then sets environment to production and compiles js and css into build.

## Other NPM Scripts
You can run any of these individually if you'd like with the `npm run` command:
Expand All @@ -49,8 +60,9 @@ You can run any of these individually if you'd like with the `npm run` command:
* `lint` - Runs lint on the `src/js` folder and uses the `.eslintrc` file in root for linting rules
* `webpack-server` - Start up a webpack-dev-server with hot-module-replacement
* `webpack-watch` - Run webpack in dev environment with watch
* `dev:dir` - Copy files and folders from `src/assets` to `build/dev`
* `dev:js` - Run webpack in dev environment without watch
* `build:dir` - Copy files and folders from `src/public` to `build`
* `build:dir` - Copy files and folders from `src/assets` to `build/prod`
* `build:js` - Run webpack in production environment

## Input Controls
Expand Down
1 change: 0 additions & 1 deletion build/css/0.css

This file was deleted.

15 changes: 0 additions & 15 deletions build/index.html

This file was deleted.

1 change: 0 additions & 1 deletion build/js/0.app.js

This file was deleted.

1 change: 0 additions & 1 deletion build/js/0.app.js.map

This file was deleted.

13 changes: 0 additions & 13 deletions build/js/2.app.js

This file was deleted.

1 change: 0 additions & 1 deletion build/js/2.app.js.map

This file was deleted.

1 change: 0 additions & 1 deletion build/js/app.js

This file was deleted.

1 change: 0 additions & 1 deletion build/js/app.js.map

This file was deleted.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@
"author": "Paul Graffam",
"main": "app.js",
"scripts": {
"dev": "run-s dev:js webpack-server",
"dev": "run-s dev:dir dev:js webpack-server",
"build": "run-s prebuild build:dir build:js",
"prebuild": "run-s clean lint",
"clean": "rimraf build",
"clean": "rimraf build/prod",
"lint": "eslint src/js/",
"webpack-server": "webpack-dev-server --env.NODE_ENV=dev --progress --color --open --hot",
"webpack-watch": "webpack --env.NODE_ENV=dev --progress --color --watch --hot",
"dev:dir": "copyfiles -a -u 2 src/assets/**/*.* build/dev/assets",
"dev:js": "webpack --env.NODE_ENV=dev",
"build:dir": "copyfiles -a -u 2 src/public/assets/**/*.* build/",
"build:dir": "copyfiles -a -u 2 src/assets/**/*.* build/prod/assets",
"build:js": "webpack --env.NODE_ENV=prod --progress --color"
},
"dependencies": {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions src/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
</section>

<% if (htmlWebpackPlugin.options.env === 'dev') { %>
<script src="js/rStats.js"></script>
<script src="js/rStats.extras.js"></script>
<script src="js/dat.gui.min.js"></script>
<script src="assets/vendor/rstats/rStats.js"></script>
<script src="assets/vendor/rstats/rStats.extras.js"></script>
<script src="assets/vendor/datgui/dat.gui.min.js"></script>
<% } %>
</body>
</html>
2 changes: 1 addition & 1 deletion src/js/app/helpers/stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default class Stats {
tS = new threeStats(this.renderer.threeRenderer);

rS = new rStats({
CSSPath: './css/',
CSSPath: './assets/vendor/rstats/',
userTimingAPI: true,
values: {
frame: { caption: 'Total frame time (ms)', over: 16, average: true, avgMs: 100 },
Expand Down
1 change: 0 additions & 1 deletion src/public/assets/models/Teapot.json

This file was deleted.

Binary file removed src/public/assets/textures/UV_Grid_Sm.jpg
Binary file not shown.
77 changes: 0 additions & 77 deletions src/public/css/main.css

This file was deleted.

19 changes: 0 additions & 19 deletions src/public/index.html

This file was deleted.

Loading