Skip to content

Commit

Permalink
Reload Browsersync on changes to CSS and JS files
Browse files Browse the repository at this point in the history
  • Loading branch information
esjay committed Nov 17, 2020
1 parent a1e8660 commit 86c85c0
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 11 deletions.
8 changes: 5 additions & 3 deletions .eleventy.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ module.exports = function (eleventyConfig) {

// Directories
eleventyConfig.addPassthroughCopy("./src/fonts");
eleventyConfig.addPassthroughCopy({
"./tmp/_dist/css": "css",
"./tmp/_dist/js": "js",
});

// Social Media
eleventyConfig.addPassthroughCopy("./src/apple-touch-icon.png");
Expand Down Expand Up @@ -104,9 +108,7 @@ module.exports = function (eleventyConfig) {
return content;
});

eleventyConfig.addWatchTarget("./dist/css/");
eleventyConfig.addWatchTarget("./dist/img/");
eleventyConfig.addWatchTarget("./dist/js/");
eleventyConfig.setUseGitIgnore(false);

return {
templateFormats: [
Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@
"images:2-build-svg": "svgo dist/img/**/*.svg",
"scripts": "run-s scripts:*",
"scripts:0-lint": "jshint --reporter=node_modules/jshint-stylish src/js/",
"scripts:1-concat": "mkdir -p dist/js && concat-glob 'src/js/**/*.js' -o 'dist/js/main.js'",
"scripts:2-optimize": "mv dist/js/main.js dist/js/main.temp.js && optimize-js dist/js/main.temp.js > dist/js/main.js && rm dist/js/main.temp.js",
"scripts:3-minify": "uglifyjs --compress --mangle -o 'dist/js/main.min.js' -- 'dist/js/main.js' ",
"scripts:1-concat": "mkdir -p tmp/_temp/js && concat-glob 'src/js/**/*.js' -o 'tmp/_temp/js/main.js'",
"scripts:2-optimize": "mkdir -p tmp/_dist/js && mv tmp/_temp/js/main.js tmp/_temp/js/main.temp.js && optimize-js tmp/_temp/js/main.temp.js > tmp/_temp/js/main.js && rm tmp/_temp/js/main.temp.js",
"scripts:3-minify": "uglifyjs --compress --mangle -o 'tmp/_dist/js/main.min.js' -- 'tmp/_temp/js/main.js' ",
"styleguide": "kss --source src/css --css ../css/screen.min.css --destination dist/styleguide --placeholder [modifier] --title 'Styleguide - The A11Y Project'",
"styles": "run-s styles:*",
"styles:0-lint": "stylelint \"src/css/**/*.scss\" --syntax scss",
"styles:1-sass": "node-sass src/css/screen.scss dist/css/temp/screen.css",
"styles:2-autoprefix": "npx postcss dist/css/temp/screen.css --use autoprefixer -d dist/css/temp/autoprefix",
"styles:3-purge": "mkdir -p dist/css/temp/purge && purgecss --css dist/css/temp/autoprefix/screen.css --content \"src/**/*.{njk,md}\" -o dist/css/temp/purge/",
"styles:4-minify": "npx postcss dist/css/temp/purge/screen.css > dist/css/screen.min.css --use cssnano",
"styles:5-cleanup": "rm -rf dist/css/temp/",
"styles:1-sass": "node-sass src/css/screen.scss tmp/_temp/css/temp/screen.css",
"styles:2-autoprefix": "npx postcss tmp/_temp/css/temp/screen.css --use autoprefixer -d tmp/_temp/css/temp/autoprefix",
"styles:3-purge": "mkdir -p tmp/_temp/css/temp/purge && purgecss --css tmp/_temp/css/temp/autoprefix/screen.css --content \"src/**/*.{njk,md}\" -o tmp/_temp/css/temp/purge/",
"styles:4-minify": "mkdir -p tmp/_dist/css && npx postcss tmp/_temp/css/temp/purge/screen.css > tmp/_dist/css/screen.min.css --use cssnano",
"styles:5-cleanup": "rm -rf tmp/_temp/css/temp/",
"watch:images": "watch -p \"src/img/**/*.{jpg,jpeg,gif,webm,webp,png,svg}\" -c \"npm run images\"",
"watch:scripts": "watch -p \"src/js/**/*.js\" -c \"npm run scripts\"",
"watch:styles": "watch -p \"src/css/**/*.scss\" -c \"npm run styles\""
Expand Down
62 changes: 62 additions & 0 deletions src/.eleventyignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,64 @@
css/
img/

# Project-specific files and folders
dist/

# Generic files to ignore
*~
*.DS_Store
._*
*.lock
*.out
*.swp
.AppleDouble
.LSOverride
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db


# Project Files
*.project
*.settings
*.tmproj
*.sublime-project
*.sublime-workspace
*.esproj
*.expressostorage
*.orig
_notes
codekit-config.json
dwsync.xml
node_modules
npm-debug.log


# Compiled source
*.com
*.class
*.dll
*.exe
*.o
*.so


# Logs and databases
*.log
*.sql
*.sqlite


# Packages (better to unpack these files and commit the raw source)
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip

# Local Netlify folder
.netlify

0 comments on commit 86c85c0

Please sign in to comment.