From 02eb68329857c6469e994551db614f29985318a3 Mon Sep 17 00:00:00 2001 From: Paulo Jorge Reis Date: Fri, 16 Nov 2018 11:37:29 +0000 Subject: [PATCH] Merge pull request #1113 from sharelatex/pr-compile-only-ol-dark-dev Move LESS compilation process to Makefile GitOrigin-RevId: 5a3871759eda2685ec0690899b0904d45c7db0a6 --- services/web/.gitignore | 9 +++-- services/web/Makefile | 35 +++++++++++++++---- services/web/package.json | 6 ++-- .../web/public/stylesheets/ol-ieee-style.less | 6 ++++ .../public/stylesheets/ol-light-style.less | 4 +++ services/web/public/stylesheets/ol-style.less | 4 +++ services/web/public/stylesheets/style.less | 5 +++ 7 files changed, 55 insertions(+), 14 deletions(-) create mode 100644 services/web/public/stylesheets/ol-ieee-style.less diff --git a/services/web/.gitignore b/services/web/.gitignore index fdb07e0c6b..708048810b 100644 --- a/services/web/.gitignore +++ b/services/web/.gitignore @@ -64,16 +64,15 @@ public/js/modules/ public/js/services/ public/js/utils/ -public/stylesheets/style.css -public/stylesheets/ol-style.css -public/stylesheets/ol-light-style.css +public/stylesheets/style*.css +public/stylesheets/ol-style*.css +public/stylesheets/ol-light-style*.css +public/stylesheets/ol-ieee-style*.css public/stylesheets/*.map public/minjs/ Gemfile.lock -public/stylesheets/ol-style.*.css -public/stylesheets/style.*.css public/js/libs/require*.js diff --git a/services/web/Makefile b/services/web/Makefile index 5c9293096e..370695fa4b 100644 --- a/services/web/Makefile +++ b/services/web/Makefile @@ -8,6 +8,8 @@ MODULE_MAKEFILES := $(MODULE_DIRS:=/Makefile) COFFEE := node_modules/.bin/coffee $(COFFEE_OPTIONS) BABEL := node_modules/.bin/babel GRUNT := node_modules/.bin/grunt +LESSC := node_modules/.bin/lessc +CLEANCSS := node_modules/.bin/cleancss APP_COFFEE_FILES := $(shell find app/coffee -name '*.coffee') FRONT_END_SRC_FILES := $(shell find public/src -name '*.js') @@ -20,7 +22,19 @@ SRC_FILES := $(FRONT_END_SRC_FILES) $(TEST_SRC_FILES) JS_FILES := $(subst coffee,js,$(COFFEE_FILES)) OUTPUT_SRC_FILES := $(subst src,js,$(SRC_FILES)) LESS_FILES := $(shell find public/stylesheets -name '*.less') -CSS_FILES := public/stylesheets/style.css public/stylesheets/ol-style.css public/stylesheets/ol-light-style.css +LESSC_COMMON_FLAGS := --source-map --autoprefix="last 2 versions, ie >= 10" +CLEANCSS_FLAGS := --s0 --source-map + +LESS_SL_FILE := public/stylesheets/style.less +CSS_SL_FILE := public/stylesheets/style.css +LESS_OL_FILE := public/stylesheets/ol-style.less +CSS_OL_FILE := public/stylesheets/ol-style.css +LESS_OL_LIGHT_FILE := public/stylesheets/ol-light-style.less +CSS_OL_LIGHT_FILE := public/stylesheets/ol-light-style.css +LESS_OL_IEEE_FILE := public/stylesheets/ol-ieee-style.less +CSS_OL_IEEE_FILE := public/stylesheets/ol-ieee-style.css + +CSS_FILES := $(CSS_SL_FILE) $(CSS_OL_FILE) $(CSS_OL_LIGHT_FILE) $(CSS_OL_IEEE_FILE) # The automatic variable $(@D) is the target directory name app.js: app.coffee @@ -81,18 +95,27 @@ public/js/main.js: public/src/main.js $(MODULE_MAIN_SRC_FILES) sed -e s=\'__MAIN_CLIENTSIDE_INCLUDES__\'=$$INCLUDES= \ > $@ -$(CSS_FILES): $(LESS_FILES) - $(GRUNT) compile:css +public/stylesheets/%.css: $(LESS_FILES) + $(LESSC) $(LESSC_COMMON_FLAGS) $(@D)/$*.less $(@D)/$*.css + +css_full: $(CSS_FILES) + +css: $(CSS_OL_FILE) minify: $(CSS_FILES) $(JS_FILES) $(OUTPUT_SRC_FILES) $(GRUNT) compile:minify + $(MAKE) minify_css $(MAKE) minify_es +minify_css: $(CSS_FILES) + $(CLEANCSS) $(CLEANCSS_FLAGS) -o $(CSS_SL_FILE) $(CSS_SL_FILE) + $(CLEANCSS) $(CLEANCSS_FLAGS) -o $(CSS_OL_FILE) $(CSS_OL_FILE) + $(CLEANCSS) $(CLEANCSS_FLAGS) -o $(CSS_OL_LIGHT_FILE) $(CSS_OL_LIGHT_FILE) + $(CLEANCSS) $(CLEANCSS_FLAGS) -o $(CSS_OL_IEEE_FILE) $(CSS_OL_IEEE_FILE) + minify_es: npm -q run webpack:production -css: $(CSS_FILES) - compile: $(JS_FILES) $(OUTPUT_SRC_FILES) css public/js/main.js public/js/ide.js @$(MAKE) compile_modules @@ -105,7 +128,7 @@ compile_full: $(COFFEE) -o test/unit/js -c test/unit/coffee $(BABEL) test/unit_frontend/src --out-dir test/unit_frontend/js rm -f public/js/ide.js public/js/main.js # We need to generate ide.js, main.js manually later - $(MAKE) $(CSS_FILES) + $(MAKE) css_full $(MAKE) compile_modules_full $(MAKE) compile # ide.js, main.js, share.js, and anything missed diff --git a/services/web/package.json b/services/web/package.json index f3ebc53f66..051e57a4df 100644 --- a/services/web/package.json +++ b/services/web/package.json @@ -119,7 +119,7 @@ "bunyan": "0.22.1", "chai": "3.5.0", "chai-spies": "", - "clean-css": "^3.4.18", + "clean-css-cli": "^4.2.1", "coffee-script": "^1.7.1", "es6-promise": "^4.0.5", "eslint": "^4.18.1", @@ -143,7 +143,6 @@ "grunt-cli": "^1.2.0", "grunt-contrib-clean": "0.5.0", "grunt-contrib-coffee": "0.10.0", - "grunt-contrib-less": "1.4.x", "grunt-contrib-requirejs": "0.4.1", "grunt-contrib-watch": "^1.0.0", "grunt-env": "0.4.4", @@ -155,7 +154,6 @@ "grunt-mocha-test": "0.9.0", "grunt-newer": "^1.2.0", "grunt-parallel": "^0.5.1", - "grunt-postcss": "^0.8.0", "grunt-sed": "^0.1.1", "grunt-shell": "^2.1.0", "handlebars-loader": "^1.7.0", @@ -166,6 +164,8 @@ "karma-mocha-reporter": "^2.2.5", "karma-requirejs": "^1.1.0", "karma-webpack": "^2.0.9", + "less": "^2.7.3", + "less-plugin-autoprefix": "^2.0.0", "mkdirp": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", "nodemon": "^1.14.3", "prettier-eslint-cli": "^4.7.1", diff --git a/services/web/public/stylesheets/ol-ieee-style.less b/services/web/public/stylesheets/ol-ieee-style.less new file mode 100644 index 0000000000..7484073d2c --- /dev/null +++ b/services/web/public/stylesheets/ol-ieee-style.less @@ -0,0 +1,6 @@ +@import "ol-style.less"; +@import "core/ol-light-variables.less"; + +@is-overleaf : true; +@is-overleaf-light : false; +@show-rich-text : true; \ No newline at end of file diff --git a/services/web/public/stylesheets/ol-light-style.less b/services/web/public/stylesheets/ol-light-style.less index 14fc37b602..1b7bee169f 100644 --- a/services/web/public/stylesheets/ol-light-style.less +++ b/services/web/public/stylesheets/ol-light-style.less @@ -1,2 +1,6 @@ @import "ol-style.less"; @import "core/ol-light-variables.less"; + +@is-overleaf : true; +@is-overleaf-light : true; +@show-rich-text : true; diff --git a/services/web/public/stylesheets/ol-style.less b/services/web/public/stylesheets/ol-style.less index 455d63016c..6518e1c314 100644 --- a/services/web/public/stylesheets/ol-style.less +++ b/services/web/public/stylesheets/ol-style.less @@ -1,6 +1,10 @@ @import url(https://fonts.googleapis.com/css?family=Lato:300,400,700&subset=latin-ext); @import url(https://fonts.googleapis.com/css?family=Merriweather:400,400i,700,700i); +@is-overleaf : true; +@is-overleaf-light : false; +@show-rich-text : true; + // Core variables and mixins @import "core/ol-variables.less"; @import "app/ol-style-guide.less"; diff --git a/services/web/public/stylesheets/style.less b/services/web/public/stylesheets/style.less index ae5820453f..a088397598 100755 --- a/services/web/public/stylesheets/style.less +++ b/services/web/public/stylesheets/style.less @@ -1,6 +1,11 @@ @import url(https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700); @import url(https://fonts.googleapis.com/css?family=Merriweather:400,400i,700,700i); + +@is-overleaf : false; +@is-overleaf-light : false; +@show-rich-text : false; + // Core variables and mixins @import "core/variables.less"; @import "_style_includes.less"; \ No newline at end of file