add make targets for js and css, add js linter (#6952)
* add make targets for js,css, add javascript linter - add `make js`, deprecating `make javascripts` - add `make css`, deprecating `make generate-stylesheets` and `make stylesheets-check` - changed the unclean css check to only run on CI - add JS linting via eslint with basic configuration and fixed discovered issues - changed autoprefixer to use official `postcss-cli` avoiding the need to loop in the makefile - moved browserslist to package.json so other future tools can use it too. - update documentation for new make targets and added JS section * fix indentation * move functions used in html to 'exported' list * Run lessc binary without having to install anything to node_modules * use relative paths to node bin scripts, removing npx * Revert "use relative paths to node bin scripts, removing npx" This reverts commit 119b725525a8430b32ee7a6e6009b4ece544e39b. * fix lessc and postcss plugins * check for node_modules and use actual bin names
This commit is contained in:
parent
775a5a5b0f
commit
d9dcd09340
9 changed files with 891 additions and 132 deletions
60
Makefile
60
Makefile
|
@ -365,33 +365,55 @@ release-compress:
|
|||
fi
|
||||
cd $(DIST)/release/; for file in `find . -type f -name "*"`; do echo "compressing $${file}" && gxz -k -9 $${file}; done;
|
||||
|
||||
.PHONY: javascripts
|
||||
javascripts: public/js/index.js
|
||||
|
||||
.IGNORE: public/js/index.js
|
||||
public/js/index.js: $(JAVASCRIPTS)
|
||||
cat $< >| $@
|
||||
|
||||
.PHONY: stylesheets-check
|
||||
stylesheets-check: generate-stylesheets
|
||||
@diff=$$(git diff public/css/*); \
|
||||
if [ -n "$$diff" ]; then \
|
||||
echo "Please run 'make generate-stylesheets' and commit the result:"; \
|
||||
echo "$${diff}"; \
|
||||
.PHONY: js
|
||||
js:
|
||||
@if ([ ! -d "$(PWD)/node_modules" ]); then \
|
||||
echo "node_modules directory is absent, please run 'npm install' first"; \
|
||||
exit 1; \
|
||||
fi;
|
||||
|
||||
.PHONY: generate-stylesheets
|
||||
generate-stylesheets:
|
||||
@hash npx > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
||||
echo "Please install npm version 5.2+"; \
|
||||
exit 1; \
|
||||
fi;
|
||||
$(eval BROWSERS := "> 1%, last 2 firefox versions, last 2 safari versions, ie 11")
|
||||
npx lesshint public/less/
|
||||
npx eslint public/js
|
||||
|
||||
.PHONY: css
|
||||
css:
|
||||
@if ([ ! -d "$(PWD)/node_modules" ]); then \
|
||||
echo "node_modules directory is absent, please run 'npm install' first"; \
|
||||
exit 1; \
|
||||
fi;
|
||||
@hash npx > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
||||
echo "Please install npm version 5.2+"; \
|
||||
exit 1; \
|
||||
fi;
|
||||
|
||||
npx lesshint public/less/
|
||||
npx lessc --clean-css="--s0 -b" public/less/index.less public/css/index.css
|
||||
$(foreach file, $(filter-out public/less/themes/_base.less, $(wildcard public/less/themes/*)),npx lessc --clean-css="--s0 -b" public/less/themes/$(notdir $(file)) > public/css/theme-$(notdir $(call strip-suffix,$(file))).css;)
|
||||
$(foreach file, $(wildcard public/css/*),npx postcss --use autoprefixer --autoprefixer.browsers $(BROWSERS) -o $(file) $(file);)
|
||||
npx postcss --use autoprefixer --no-map --replace public/css/*
|
||||
|
||||
@diff=$$(git diff public/css/*); \
|
||||
if ([ ! -z "$CI" ] && [ -n "$$diff" ]); then \
|
||||
echo "Generated files in public/css have changed, please commit the result:"; \
|
||||
echo "$${diff}"; \
|
||||
exit 1; \
|
||||
fi;
|
||||
|
||||
.PHONY: javascripts
|
||||
javascripts:
|
||||
echo "'make javascripts' is deprecated, please use 'make js'"
|
||||
$(MAKE) js
|
||||
|
||||
.PHONY: stylesheets-check
|
||||
stylesheets-check:
|
||||
echo "'make stylesheets-check' is deprecated, please use 'make css'"
|
||||
$(MAKE) css
|
||||
|
||||
.PHONY: generate-stylesheets
|
||||
generate-stylesheets:
|
||||
echo "'make generate-stylesheets' is deprecated, please use 'make css'"
|
||||
$(MAKE) css
|
||||
|
||||
.PHONY: swagger-ui
|
||||
swagger-ui:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue