Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

appstackr

benpptung6MIT0.3.18

Enjoy Multiple Screens Live Reload and app building at the same time

assets, autoprefixer, browser-sync, browserify, build, bundle, cdn, css, javascript, less, minifier, packager, ractive, react, sass, stylus

readme

appstackr

A personal opinioned tool to strategically stack up front-end bundles from js, jsx, css, scss, less, stylus, html-styled template files( swig, ractive, mustache ), or pure html files. Using browserify, browser-sync, uglifyjs, auto-prefixer, htmlcompressor..etc.

Add hashes to the stacked bundles. So the browser can long-term cache js, image and css files. Speed up website in production environment.

Beware to use this tool. It is only working and tested on node.js 4.4.3, so there should be some problems if node.js > 4.4.3.

Todo list

  • switch Gaze to chalk.
  • multiple stack files to separate concerns
  • update modules
  • rewrite entirely to make it easy to maintain

Installation

Install to the project as local dependency

$ npm install appstackr --save-dev

Edit package.json script property as following( use express as example )

"scripts": {
    "start"   : "DEBUG=<app_name>:* node ./bin/www",
    "appbuild": "appbuild",
    "appstack": "appstack",
    "appwatch": "appwatch --server 0.0.0.0:3000",
    "bsync"   : "npm start & npm run appwatch"
     }

Add a stacks.js file like following

module.exports = [
  {
    name: 'base/site',
    nature: 'js',
    files: 'path/to/client/**/*.js'
  },
  {
    name: 'base/site',
    nature: 'css',
    files: [
      'path/to/client/**/*.css',
      'path/to/client/**/*.scss',
      'path/to/client/**/*.less',
      'path/to/client/**/*.styl'
    ]
  }
];

Stack up front-end bundles /js/base/site.min.js and /css/base/site.min.css

$ npm run appstack

Run command

$ npm run bsync

Find the view files, edit the src and href pointed to /js/base/site.min.js and /css/base/site.min.css

Example:

https://github.com/benpptung/appstackr-examples

Generate an express project with appstackr installed

Make sure express-generator is not installed, or remove it temporally

Install the generator:

$ npm install -g benpptung/generator

create the app:

$ express /tmp/foo && cd /tmp/foo

Install dependencies:

$ npm install

Stack up front-end bundles:

$ npm run appstack

Start server & appwatch together

$ npm run bsync
Stack up bundles while starting appwatch
"appwatch": "appwatch -i --server 0.0.0.0:3000"
Use browser-sync server ( No your own routes & views )

appstackr will direct browser-sync to watch public folder, which is defined in global config, or appstackr-settings.json

"appwach": "appwatch -b"

$ npm run appwatch

Usage

stacks.js setup

module.exports = [
  {
    name: 'site',
    nature: 'js',
    files: 'client/site/**/*.js'
  },
  {
  ...
  }
];

stacks.js options

  • name: string e.g. site or base/site
  • files: glob pattern, or path resolved to a node module of array, e.g. site/**/*.js, react, react/addons
  • watch: array or string, to watch the files not included in files array. Useful for files required/imported in js or css files.
  • nature: js|jhtml|css|chtml|html
  • commonjs: true, if nature is js|jhtml and browserify options. commonjs is auto set to true
  • browserfiy: browserify() options. Three additonal options: exposes, externals, ignores.
  • autoprefixer: auto-prefixer options to define which browsers want to support.
Example to bundle modules into stacks
module.exports = [
  {
    name: 'base/bundle',
    nature: 'js',
    files: 'superagent, insert-css',
    browserify:{
      exposes: '*' // Make all modules outside the bundle with require().
    }
  },
  {
    name: 'base/site',
    nature: 'js',
    files: [
      'client/helper.js'
      'node_modules/public-browserify/react.js'
    ],
    browserify: {
      exposes: [
      'helper.js:helper',
      'react.js:react'
      ]
      // Make private module outside the bundle using <file_name>:<module_name> pattern
    }
  },
  {
    name: 'base/shim',
    nature: 'js',
    files: [
      'node_modules/es5-shim/es5-shim.min.js',
      'node_modules/es5-shim/es5-sham.min.js',
      'node_modules/console-polyfill/index.js',
      'node_modules/html5shiv/dist/html5shiv.min.js',
      'node_modules/respond.js/dest/respond.matchmedia.addListener.min.js'
    ]
    // concat plain js files
  },
]
browserify tranforms support

Require scss|less|styl|css file directly in js or jsx

var React = require('react');
var insCSS = require('insert-css');

insCSS(require('./assets/style.scss'));

module.exports = React.createClass(...);
react.js support
  1. Put .jsx file in a stack.
  2. or require .jsx file in the codes.
auto-prefixer support
module.exports = [
  {
    "name": "bootstrap",
    "nature": "css",
    "files": [
      "less/bootstrap/bootstrap.less"
    ],
    "autoprefixer": "> 5%, IE 8"
  },
]

Default directory structure

|-- public ( hold the js/css/image files )
|
|-- views ( hold the view files for server routes )      
|
|-- stacks.js ( how to stack up front-end bundles )
|
\-- appstackr-settings.json ( configure appstackr, e.g. define your own public js folder name )

appbuild

$ npm run appbuild

Create dist folder, auto-refactor the views, public assests. Upload public assets to cdn server, and point views folder to dist/views in production environment.

Debug

appstackr has no source map. To figure out what's wrong, use the following command to beautify the codes and see where the error is in browser console. If not sure which source file it is, use stacks.js as an index. e.g. to check example.min.js

$ npm run appstack -- -bf example:js

Benefits

  1. appstackr is designed as a local dependency in a project. That said, if you upgrade your global build tool, it's very possible your next building results of js|css files will be changed. Thereafter, in your CDN, these static files will have different version hash tags, then your customers are forced to reload the new static files, just because you upgrade your build tool.

  2. appstackr is not designed to be a public project or replace other tools. It's just a personal opinioned tool in my produciton environment, continuely improvement is for sure.

  3. appstackr is an inspiration after couple years using ANT to maintain my websites. It had been a nightmare, and I don't want it to happen again. One of the most important priority in appstackr is less is more, including no more verbose syntax in building script, easy to tell where are the source files, and where are the destination files.

changelog

Changelog

3.3.0

  • Improve libsass compatibility
  • Support using Bower package with Rails

3.2.0.2

Main bootstrap file is now a partial (_bootstrap.scss), for compatibility with Compass 1+.

Fixed a number of bugs. Issues closed in v3.2.0.2.

3.2.0.1

Fixed a number of bugs: Issues closed in v3.2.0.1.

3.2.0.0

  • Assets (Sass, JS, fonts) moved from vendor/assets to assets. bootstrap.js now contains concatenated JS.
  • Compass generator now copies JS and fonts, and provides a better default styles.sass.
  • Compass, Sprockets, and Mincer asset path helpers are now provided in pure Sass: bootstrap-compass, bootstrap-sprockets, and bootstrap-mincer. Asset path helpers must be imported before bootstrap, more in Readme.
  • Sprockets / Mincer JS manifest has been moved to bootstrap-sprockets.js. It can be required without adding Bootstrap JS directory to load path, as it now uses relative paths.
  • Sprockets: depend_on_asset (glyphicons.scss) has been changed to depend_on to work around an issue with depend_on_asset. More information.

3.1.1.0

  • Updated Bower docs

3.1.0.2

  • 523: Rails 3.2 compatibility

  • Bugfixes from upstream up to 7eb532262fbd1112215b5a547b9285794b5360ab.

3.1.0.1

  • 518: scale mixin Sass compatibility issue

3.1.0.0

  • compiles with libsass master

3.0.2.1

  • fix vendor paths for compass

3.0.0.0

  • Fully automated (lots of string juggling) LESS -> Sass conversion. - Gleb Mazovetskiy
  • Ported rake task from vwall/compass-twitter-bootstrap to convert Bootstrap upstream - Peter Gumeson
  • Moved javascripts to us bootstrap-component.js to bootstrap/component.js - Peter Gumeson

2.3.2.2

  • Allow sass-rails >= 3.2 - Thomas McDonald

2.3.2.1

2.3.2.0

  • Update to Bootstrap 2.3.2 - Dan Allen

2.3.1.3

  • Find the correct Sprockets context for the image_path function - Tristan Harward, Gleb Mazovetskiy

2.3.1.2

  • Fix changes to image url - Gleb Mazovetskiy
  • Copy _variables into project on Compass install - Phil Thompson
  • Add bootstrap-affix to the Compass template file - brief

2.3.1.1 (yanked)

  • Change how image_url is handled internally - Tristan Harward
  • Fix some font variables not having !default - Thomas McDonald

2.3.0.0

  • [#290] Update to Bootstrap 2.3.0 - Tristan Harward
  • Fix rake:debug with new file locations - Thomas McDonald
  • Add draft contributing document - Thomas McDonald
  • [#260] Add our load path to the global Sass load path - Tristan Harward
  • [#275] Use GitHub notation in Sass head testing gemfile - Timo Schilling
  • [#279, #283] Readme improvements - theverything, Philip Arndt

2.2.2.0

  • [#270] Update to Bootstrap 2.2.2 - Tristan Harward
  • [#266] Add license to gemspec - Peter Marsh

2.2.1.1

  • [#258] Use bootstrap prefix for @importing files in bootstrap/bootstrap.scss - Umair Siddique

2.2.1.0

  • [#246] Update to Bootstrap 2.2.1 - Tristan Harward
  • [#246] Pull Bootstrap updates from jlong/sass-twitter-bootstrap - Tristan Harward

2.1.1.0

  • Update to Bootstrap 2.1.1
  • [#222] Remove 100% multiplier in vertical-three-colours
  • [#227] Fix IE component animation collapse
  • [#228] Fix variables documentation link
  • [#231] Made .input-block-level a class as well as mixin

2.1.0.1

  • [#219] Fix expected a color. Got: transparent.
  • [#207] Add missing warning style for table row highlighting
  • [#208] Use grid-input-span for input spans

2.1.0.0

  • Updated to Bootstrap 2.1
  • Changed some mixin names to be more consistent. Nested mixins in Less are separated by a - when they are flattened in Sass.

2.0.4.1

  • Fix .row-fluid > spanX nesting
  • Small Javascript fixes for those staying on the 2.0.4 release
  • Add !default to z-index variables.

2.0.4.0

  • Updated to Bootstrap 2.0.4
  • Switched to Bootstrap 2.0.3+'s method of separating responsive files
  • [#149, #150] Fix off by one error introduced with manual revert of media query breakpoints
  • rake debug and rake test both compile bootstrap & bootstrap-responsive

2.0.3.1

  • [#145, #146] Fix button alignment in collapsing navbar as a result of an incorrect variable

2.0.3

  • Updated to Bootstrap 2.0.3
  • [#106] Support for Rails < 3.1 through Compass
  • [#132] Add CI testing
  • [#106] Support Rails w/Compass
  • [#134] Fix support for Rails w/Compass

2.0.2

  • [#86] Updated to Bootstrap 2.0.2 Things of note: static navbars now have full width. (to be fixed in 2.0.3) .navbar-inner > .container { width:940px; } seems to work in the meanwhile
  • [#62] Fixed asset compilation taking a very long time.
  • [#69, #79, #80] (Hopefully) clarified README. Now with less cat humour.
  • [#91] Removed doubled up Sass extensions for Rails.
  • [#63, #73] Allow for overriding of image-path
  • [SO] Added makeFluidColumn mixin for defining fluid columns. Fluid rows must use @extend .row-fluid, and any column inside it can use @include makeFluidColumn(num), where num is the number of columns. Unfortunately, there is a rather major limitation to this: margins on first-child elements must be overriden. See the attached Stack Overflow answer for more information.

2.0.1

  • Updated to Bootstrap 2.0.1
  • Modified @mixin opacity() to take an argument 0...1 rather than 0...100 to be consistent with Compass.

2.0.0

  • Updated to Bootstrap 2.0.0