Last active
February 20, 2020 15:00
-
-
Save rizkysyazuli/813e7850df89d49d38ffe39ec7a2e6d8 to your computer and use it in GitHub Desktop.
[Dotfiles - Static HTML Dev] Basic Grunt setup & config files #dotfiles #grunt #linter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"env": { | |
"browser": true | |
}, | |
"extends": "eslint:recommended", | |
"parser": "esprima", | |
"parserOptions": { | |
"ecmaVersion": 5, | |
"sourceType": "script" | |
}, | |
"rules": { | |
"indent": ["warn", 4], | |
"no-mixed-spaces-and-tabs": ["warn"], | |
"linebreak-style": ["error", "unix"], | |
"quotes": ["error", "single"], | |
"semi": ["off", "always"], | |
"no-unused-vars": ["off"], | |
"no-undef": ["off"], | |
"no-console": ["off"], | |
"comma-dangle": ["error", "never"], | |
"no-empty": ["warn"] | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"tagname-lowercase": true, | |
"attr-lowercase": true, | |
"attr-value-double-quotes": true, | |
"doctype-first": false, | |
"tag-pair": true, | |
"id-unique": true, | |
"src-not-empty": true, | |
"attr-no-duplication": true, | |
"title-require": true, | |
"alt-require": true, | |
"doctype-html5": true, | |
"style-disabled": false, | |
"inline-style-disabled": true, | |
"inline-script-disabled": true, | |
"space-tab-mixed-disabled": "space", | |
"id-class-ad-disabled": true | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
files: | |
include: public/**/*.s+(a|c)ss | |
options: | |
formatter: stylish | |
merge-default-rules: false | |
rules: | |
bem-depth: | |
- 1 | |
- max-depth: 1 | |
border-zero: | |
- 1 | |
- convention: zero | |
brace-style: | |
- 1 | |
- allow-single-line: false | |
class-name-format: | |
- 1 | |
- convention: hyphenatedlowercase | |
clean-import-paths: | |
- 1 | |
- filename-extension: false | |
leading-underscore: false | |
empty-line-between-blocks: | |
- 1 | |
- ignore-single-line-rulesets: false | |
extends-before-declarations: 0 | |
extends-before-mixins: 0 | |
final-newline: | |
- 1 | |
- include: true | |
force-attribute-nesting: 0 | |
force-element-nesting: 0 | |
force-pseudo-nesting: 0 | |
function-name-format: | |
- 1 | |
- allow-leading-underscore: false | |
convention: hyphenatedlowercase | |
hex-length: | |
- 1 | |
- style: short | |
hex-notation: | |
- 1 | |
- style: lowercase | |
id-name-format: | |
- 1 | |
- convention: hyphenatedlowercase | |
indentation: | |
- 1 | |
- size: 4 | |
leading-zero: | |
- 0 | |
- include: false | |
mixin-name-format: | |
- 1 | |
- allow-leading-underscore: false | |
convention: hyphenatedlowercase | |
mixins-before-declarations: 0 | |
nesting-depth: | |
- 1 | |
- max-depth: 2 | |
no-color-keywords: 1 | |
no-color-literals: 1 | |
no-css-comments: 0 | |
no-debug: 0 | |
no-duplicate-properties: 2 | |
no-empty-rulesets: 1 | |
no-extends: 0 | |
no-ids: 0 | |
no-important: 1 | |
no-invalid-hex: 1 | |
no-mergeable-selectors: 0 | |
no-misspelled-properties: | |
- 1 | |
- extra-properties: [] | |
no-qualifying-elements: | |
- 1 | |
- allow-element-with-attribute: true | |
allow-element-with-class: true | |
allow-element-with-id: true | |
no-trailing-zero: 0 | |
no-transition-all: 0 | |
no-url-protocols: 0 | |
no-vendor-prefixes: | |
- 1 | |
- additional-identifiers: [] | |
excluded-identifiers: [] | |
placeholder-in-extend: 0 | |
placeholder-name-format: | |
- 1 | |
- convention: hyphenatedbem | |
property-sort-order: | |
- 0 | |
- ignore-custom-properties: false | |
property-units: | |
- 1 | |
- global: | |
- ch | |
- em | |
- ex | |
- rem | |
- cm | |
- in | |
- mm | |
- pc | |
- pt | |
- px | |
- q | |
- vh | |
- vw | |
- vmin | |
- vmax | |
- deg | |
- grad | |
- rad | |
- turn | |
- ms | |
- s | |
- Hz | |
- kHz | |
- dpi | |
- dpcm | |
- dppx | |
- '%' | |
per-property: {} | |
quotes: | |
- 1 | |
- style: single | |
shorthand-values: | |
- 1 | |
- allowed-shorthands: | |
- 1 | |
- 2 | |
- 3 | |
single-line-per-selector: 0 | |
space-after-bang: | |
- 0 | |
- include: false | |
space-after-colon: | |
- 1 | |
- include: true | |
space-after-comma: | |
- 1 | |
- include: true | |
space-before-bang: | |
- 0 | |
- include: false | |
space-before-brace: | |
- 1 | |
- include: true | |
space-before-colon: 0 | |
space-between-parens: | |
- 1 | |
- include: false | |
trailing-semicolon: 1 | |
url-quotes: 0 | |
variable-for-property: | |
- 1 | |
- properties: [] | |
variable-name-format: | |
- 1 | |
- allow-leading-underscore: false | |
convention: hyphenatedlowercase | |
zero-unit: 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"base_url": "http://localhost/projectname", | |
"asset_path": "public/assets", | |
"template_path": "public/prototype" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
source 'https://rubygems.org' | |
gem 'compass' | |
gem 'oily_png' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function(grunt) { | |
require('load-grunt-tasks')(grunt); | |
grunt.initConfig({ | |
// Metadata | |
pkg: grunt.file.readJSON('package.json'), | |
conf: grunt.file.readJSON('config.json'), | |
// compile scss using compass | |
compass: { | |
dist: { | |
options: { | |
sourcemap: true, | |
sassDir: '<%= conf.asset_path %>/scss', | |
cssDir: '<%= conf.asset_path %>/css', | |
imagesDir: '<%= conf.asset_path %>/img', | |
javascriptsDir: '<%= conf.asset_path %>/js', | |
fontsDir: '<%= conf.asset_path %>/fonts', | |
outputStyle: 'compressed', | |
relativeAssets: true, | |
noLineComments: true, | |
httpPath: '/' | |
// list of compass plugins, if any | |
// require: ['zurb-foundation', 'susy'] | |
} | |
} | |
}, | |
// add/remove vendor prefixes | |
autoprefixer: { | |
options: { | |
browsers: ['last 2 versions'], | |
map: true | |
}, | |
css: { | |
files: [{ | |
src: '<%= conf.asset_path %>/css/main.css', | |
dest: '<%= conf.asset_path %>/css/main.css' | |
}] | |
} | |
}, | |
// minify images | |
imagemin: { | |
dist: { | |
options: { | |
optimizationLevel: 5 | |
}, | |
files: [{ | |
expand: true, | |
cwd: '<%= conf.asset_path %>/img', | |
src: '**/*.{gif,jpeg,jpg,png,svg}', | |
dest: '<%= conf.asset_path %>/img' | |
}] | |
} | |
}, | |
// compress JS files. | |
// add additional scripts in the "files" config below | |
uglify: { | |
options: { | |
mangle: false, | |
sourceMap: true, | |
report: 'none', | |
preserveComments: false, | |
compress: { | |
// drop_debugger: true, | |
// join_vars: true, | |
// drop_console: true | |
} | |
}, | |
all: { | |
files: [{ | |
src: [ | |
'<%= conf.asset_path %>/js/src/plugins.js', | |
'<%= conf.asset_path %>/js/src/main.js' | |
], | |
dest: '<%= conf.asset_path %>/js/dist/main.min.js' | |
}] | |
} | |
}, | |
// inject js & css dependencies | |
wiredep: { | |
main: { | |
src: [ | |
'<%= conf.template_path %>/**/*.{html,php}', | |
'<%= conf.asset_path %>/scss/**/*.scss' | |
] | |
} | |
}, | |
// folder cleanup | |
clean: { | |
css: ['<%= conf.asset_path %>/css/*.css'], | |
js: ['<%= conf.asset_path %>/js/dist/*.js'], | |
images: ['<%= conf.asset_path %>/img/dist'] | |
}, | |
// linters & validators | |
sasslint: { | |
options: { | |
configFile: '.sass-lint.yml' | |
}, | |
target: ['<%= conf.asset_path %>/scss/**/*.scss'] | |
}, | |
eslint: { | |
options: { | |
configFile: '.eslintrc' | |
}, | |
target: ['<%= conf.asset_path %>/js/src/*.js'] | |
}, | |
htmlhint: { | |
options: { | |
htmlhintrc: '.htmlhintrc' | |
}, | |
html: { | |
src: ['<%= conf.template_path %>/**/*.{html,php}'] | |
} | |
}, | |
// file watcher & task runner for all the previous actions above | |
watch: { | |
options: { | |
spawn: false | |
}, | |
grunt: { | |
files: 'Gruntfile.js' | |
}, | |
bower: { | |
files: 'bower.json', | |
tasks: ['wiredep'] | |
}, | |
styles: { | |
files: '<%= conf.asset_path %>/scss/**/*.scss', | |
tasks: ['compass', 'autoprefixer'] | |
}, | |
scripts: { | |
files: '<%= conf.asset_path %>/js/src/*.js', | |
tasks: ['uglify'] | |
}, | |
images: { | |
files: '<%= conf.asset_path %>/img/**/*.{gif,jpeg,jpg,png,svg}', | |
tasks: ['newer:imagemin'] | |
} | |
}, | |
browserSync: { | |
dev: { | |
bsFiles: { | |
src: [ | |
// auto reload on these changes (compiled files) | |
'<%= conf.asset_path %>/css/*.css', | |
'<%= conf.asset_path %>/js/dist/*.min.js', | |
'<%= conf.asset_path %>/img/**/*.{gif,jpeg,jpg,png,svg}', | |
'<%= conf.asset_path %>/**/*.{json,txt}', | |
'<%= conf.template_path %>/**/*.{html,php}' | |
] | |
}, | |
options: { | |
proxy: '<%= conf.base_url %>', | |
watchTask: true, | |
port: 8888 | |
} | |
} | |
} | |
}); | |
// register tasks for the command line | |
grunt.registerTask('default', ['browserSync', 'watch']); | |
grunt.registerTask('build', ['clean', 'compass', 'uglify']); | |
grunt.registerTask('lint', ['sasslint', 'eslint', 'htmlhint']); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "Project-Name", | |
"version": "1.0.0", | |
"description": "Project Name", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "Rizky Syazuli", | |
"devDependencies": { | |
"browser-sync": "^2.18.7", | |
"eslint": "^3.15.0", | |
"grunt": "^1.0.1", | |
"grunt-autoprefixer": "^3.0.4", | |
"grunt-browser-sync": "^2.2.0", | |
"grunt-contrib-clean": "^1.0.0", | |
"grunt-contrib-compass": "^1.1.1", | |
"grunt-contrib-imagemin": "^1.0.1", | |
"grunt-contrib-uglify": "^2.0.0", | |
"grunt-contrib-watch": "^1.0.0", | |
"grunt-eslint": "^19.0.0", | |
"grunt-htmlhint": "^0.9.13", | |
"grunt-newer": "^1.2.0", | |
"grunt-sass-lint": "^0.2.2", | |
"grunt-wiredep": "^3.0.1", | |
"htmlhint": "^0.9.13", | |
"load-grunt-tasks": "^3.5.2", | |
"sass-lint": "^1.10.2", | |
"time-grunt": "^1.4.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment