Package Exports
- appstackr
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (appstackr) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Appstackr
Appstackr aims to provide a simple way to manage website browser clients including Javascript, CSS and Html snippets. It is purely designed for website browser clients management.
Features
- A simplified and centralized app stacks file
stacksfile.jsto include all website html snippets, javascript, or css files. The MAIN ideas are:- Bundle all the js, css, and html files into few files, so the html won't get overwhelmed by a lot of <script> tags.
- Know where your source files coming from, and reorganize them if needed.
- No limitation how you should structure your browser clients( html/js/css files).
- URL refactor in html and css for CDN deploy. e.g.
todos.min.jsbecometodos.min-jadqu9.jsand the url in html is refactored from'/js/todos.min.js'to'//cdn.yoursite.com/js/todos.min-jadqu0.js'. So, you can simply upload all of your public files to your cdn server.
Installation
$ npm -g install appstackrHow to use
- There are two commands:
appstackandappbuild. Check How to use them via--help. Use them on your project root directory, because it will use theprocess.cwd()as the base path. - Put a
stacksfile.json your project root directory, Checkexamples/site/stacksfile.jsfor more information. It simply tell appstackr how to split yourjs,css,htmlfiles into different files. - Put an optional
appstack-profile.jsonon your project root directory. It will configure theappstackandappbuildcommand behavior.
An stacksfile.js example
module.exports = [
/*
* your site level css, it could be
* sass, less or plain css files
*/
{
"name": "site",
"nature": "css",
"files": [
"less/mastnav.less"
]
},
/*
* todos client stacks
*/
{
"name": "todos",
"nature": "js",
"files": [
"client/todos/AppView.js"
],
"commonjs": "browserify"
},
{
"name": "todos",
"nature": "css",
"files": [
"client/todos/less/todos.less"
]
},
{
"name": "todos",
"nature": "html",
"files": [
"client/todos/todos.html",
"client/todos/templates.html"
]
},
/*
* put plain js files
*/
{
"name": "bootstrap",
"nature": "js",
"files": [
"client/bootstrap/transition.js",
"client/bootstrap/alert.js",
"client/bootstrap/button.js",
"client/bootstrap/carousel.js",
"client/bootstrap/collapse.js",
"client/bootstrap/dropdown.js",
"client/bootstrap/modal.js",
"client/bootstrap/tooltip",
"client/bootstrap/popover",
"client/bootstrap/scrollspy.js",
"client/bootstrap/tab.js",
"client/bootstrap/affix.js"
]
},
{
"name": "bootstrap",
"nature": "css",
"files": [
"less/bootstrap/bootstrap.less"
]
},
{
"name": "bootstrap-theme",
"nature": "css",
"files": [
"less/bootstrap/theme.less"
]
}
]Default directory structure
|-- public
| |-- js
| |-- img
| |-- css
| \-- asset
|
|-- views
| |
| \-- snippet
|
|-- dist
|-- stacksfile.js
\-- appstack-profile.jsonWhile using command appstack, it will load the files described in stacksfile.js, concat, minifiy and write to the public and views/snippet directory.
While using command appbuild, it will copy the js, img, css, and asset directories under public folder, add version control hash, and write to dist/public directory, and refactor the urls in views and css files.
You can define your own views file extension name, currently it is default to .html and .swig
Demo
cd to the example directory examples\site
$ node server.js
Start up the server to listen on port 3000
$ appstack
The above command will create the stacks according to the appstack.js file
$ appbuild
The above command will create the files under dist direcotry.
You can check lib/profile.js for more options and configure them on appstack-profile.
For example, to configure your CDN URL, simply add the following into the appstack-profile.json
"cdn": "//{Your cdn url}/"