Vintage start project.
- Installation
- WebStorm configuration
- NPM scripts
- File structure
- JS structure explanation
- Public API
- Common scripts
- JSDoc
- Notes
In order to start working with project, you must:
npm
npm i -g jscs && npm i
yarn
yarn add global jscs && yarn install
Turn off 'Safe write' option
Settings | Appearance & Behavior | System Settings | Use "safe write"
Change ECMAScript version
Settings | Languages & Frameworks | Javascript | Javascript language version: "ECMAScript6"
Enable JSCS linter
Settings | Languages & Frameworks | Javascript | Code Quality Tools | JSCS | "Enable"
Start development
npm run development
Build production bundle (build '.min' files, prettify html)
npm run production
|-- vintage-start-project
|-- gulp
| |-- config.js
| |-- tasks
|-- src
| |-- js
| |-- styles
| |-- svg
| |-- template
|-- www
| |-- static
| | |-- js
| | |-- css
| | |-- favicon.ico
|-- .gitignore
|-- gulpfile.js
|-- jsdoc.json
|-- package.json
|-- README.md
|-- rules.jscsrc
|-- vintage-frontend.json
|-- webpack.config.js
Main JS entry point: src/js/index.ts
Will be compiled to: www/static/js/index.ts
Main SCSS entry point: src/styles/index.scss
Will be compiled to: www/static/css/index.css
Pages directory: src/template/pages
Will be compiled to: www/
Put your SVG-icons to: src/svg
Vintage-workflow will create sprite and inject it into the HTML layout (on each page)
|-- js
|-- components
|-- modules
| |-- dep
| |-- dev
|-- pages
index.ts
index.jquery.ts
PublicAPI.ts
, Common.ts
and other components (Header.js
or Footer.js
etc.).
Components from this directory should be used only by pages
and index
.
Libs and modules that could not be installed via 'npm install'
User-written modules. They shouldn't import anything (except packages from node_modules
and other modules).
Scripts for each page (will be evaluated only on corresponding page).
Path: js/components/publicAPI
(example)
Public API is created for back-end developers.
It should contain methods to attach / initialize / destroy jquery plugins etc.
If there is no need in API, simply delete publicAPI.js
file and it's import
.
Path: js/components/common
(example)
Common scripts should always be executed, regardless of active 'data-page'.
If there is no need in them, simply delete common.js
file and it's import
.
Install JSDoc globally
npm install jsdoc -g
Generate docs
npm run-script compileDocs
Open docs
npm run-script openDocs
- Each page should have corresponding
data-page
attribute (e.g.<main data-page="home" />
. - Before pushing to Bitbucket repository (or before transferring the project to Back-end department) make sure to run
production
bundle. - Ensure all of your Public API's has both
init
anddestroy
methods. - In case of Public API or Common scripts are not-in-use - make sure to delete those files.