jekyll new
migrated to npm scripts, browsersync and postcss with as few changes as possible.Still builds on GitHub*, see
http://www.filtercake.com/jekyll-npm-browsersync-postcss/
* (via checking in compiled css)
fork
for username.github.io
...
_config/.jekyllrc.yml
for other repos
_config/.jekyllrc.yml
node_modules/.bin/
"scripts"
in the package.json
"npm start"
With node-sass, this would be seamless (will maybe bild that version too).
update: it is now jekyll-npm-nodesass-postcss-browsersync :D
For postcss the sass needed some refactoring:
//
comments produce errorscalc()
All in all pretty amazing how far it works :)
node_modules/
to .gitignore
e93f473
compile without watching
script: "jekyll_compile": "jekyll build", "jekyll_compile_dev": "jekyll build --config _config.yml,_config_dev.yml",
nodemon to watch source files
By default, nodemon looks for files with the .js, .coffee, .litcoffee, and .json extensions.
./node_modules/.bin/nodemon --ext html,md,yml
nodemon can also be used to execute and monitor other programs.
ignore _site, so compiled files do not trigger re-run. only trigger compile of source files
exclude:
"jekyll_watch_compile_dev": "./node_modules/.bin/nodemon --ignore _site/ --ext html,md,yml --exec 'npm run jekyll_compile_dev'",
"browsersync_serve": "./node_modules/.bin/browser-sync start --server '_site' --files '_site'",
"start": "npm run jekyll_watch_compile_dev & browsersync_serve"
configs: jekyll, browsersync. postcss will also have config.\
why use rc files? Configuration file - Wikipedia, the free encyclopedia cmd-f "runcom"
Browsersync Command Line Usage: browser-sync init Create a configuration file
clean up existing stuff first (jekyll), then add browsersync
_config
./node_modules/.bin/browser-sync init
[BS] Config file created bs-config.js
[BS] To use it, in the same directory run: browser-sync start --config bs-config.js
mv bs-config.js _config/.browsersyncrc.js
browser-sync start --config _config/.browsersyncrc.js
"browsersync_serve": "./node_modules/.bin/browser-sync start --server '_site' --files '_site'",
"browsersync_serve": "./node_modules/.bin/browser-sync start --config _config/.browsersyncrc.js",
npm compile task
"postcss_compile": "postcss input output"
PostCSS - a tool for transforming CSS with JavaScript
npm install postcss postcss-cli postcss-scss autoprefixer precss --save
$ ./node_modules/.bin/postcss --config _config/.postcssrc.json
comments break, mixins break, interpolated vars break
do some reading
postcss postcss-cli autoprefixer
npm install postcss postcss-cli autoprefixer postcss-import postcss-simple-vars postcss-nested postcss-sassy-mixins --save
// comments produce errors
fix imports: full filenames, don't use sass import dir
interpolated variables have differing syntax :/
postcss/postcss-simple-vars: PostCSS plugin for Sass-like variables There is special syntax if you want to use variable inside CSS words:
$prefix: my-company-widget
$prefix { } $(prefix)_button { }
font declaration
darken()
refactor calculation to vanilla css calc()
ln -s _config/.jekyllrc.yml _config.yml
css is not build on gh-pages, so needs to be in ./css and checked in so it gets copied on jekyll build
after postcss, css/ needs to be copied into _site/
"postcss_compile": "./node_modules/.bin/postcss --config _config/.postcssrc.json", "postcss_copy": "cp -r css/* _site/css/", "postcss_watch_compile_copy": "./node_modules/.bin/nodemon --ignore _site/ --ignore node_modules/ --ext scss --exec 'npm run postcss_compile && npm run postcss_copy'",
"start": "npm run postcss_compile && npm run jekyll_compile_dev && npm run jekyll_watch_compile_dev & postcss_watch_compile_copy & npm run browsersync_serve"
The input can be either a single .scss or .sass, or a directory. If the input is a directory the --output flag must also be supplied.
./node_modules/.bin/node-sass --output-style expanded --source-comments --include-path _sass --follow css/main.scss css/main_roughmix.css
"sass_compile": "./node_modules/.bin/node-sass --output-style expanded --source-comments --include-path _sass --follow css/main.scss css/main_roughmix.postcss",
"sass_watch_compile": "./node_modules/.bin/nodemon --ignore _site/ --ignore node_modules/ --ext scss --exec 'npm run sass_compile'",
======================================== DEPRECATED
./node_modules/.bin/browser-sync start --server "_site/" --proxy '/jekyll-npm-browsersync-postcss/'
./node_modules/.bin/browser-sync start --proxy 'http://127.0.0.1:4000/jekyll-npm-browsersync-postcss/' --serveStatic '_site'
./node_modules/.bin/browser-sync start --proxy 'http://127.0.0.1:4000/jekyll-npm-browsersync-postcss/' --serveStatic '_site' --files '_site'
browser-sync start --proxy 'mylocal.dev' --serveStatic 'public'
As the Browsersync CLI docs tell us we can init a configuration file by doing ./node_modules/.bin/browser-sync init
. (We need to prepend the local path because we didn't install browsersync globally, but only locally.)
That command should return something like
[BS] Config file created bs-config.js
[BS] To use it, in the same directory run: browser-sync start --config bs-config.js
Again we have to prepend the command with the local path though: ./node_modules/.bin/browser-sync start --config bs-config.js
$ browser-sync start --config 'conf/browser-sync.js'
module.exports = { server: { baseDir: '_site' }
};
module.exports = { debugInfo: true, files: [ '_site/.css', '_site/**/.html' ], ghostMode: { forms: true, links: true, scroll: true }, server: { baseDir: '_site' } };