From 123e51f4d537b516729aef4f04dca944efdbea1b Mon Sep 17 00:00:00 2001 From: Simon Lejeune Date: Mon, 6 Jun 2016 16:30:15 +0200 Subject: [PATCH] [REF] ir_qweb: less webasset: compress output instead of minifying it * Remove dependency on less-plugin-clean-css which distribution packages are broken on debian stretch and derivated. * Updated documentation. * Lessc provides a `--compress` argument that could solve this issue. According to the documentation at http://lesscss.org/usage/: "[...] Compress using less built-in compression. This does an okay job but does not utilise all the tricks of dedicated css compression[...]" However, using this argument works on lessc 2.5.3 but not on 1.4.2 (`--compress` arg is present but seems to be break some rules i haven't been able to put my finger on). * Finally, use the minification of the StylesheetAsset that takes care of removing the spaces, the comments and the sourcemap with regexes. fixes issue #9113 --- debian/control | 1 - doc/setup/install.rst | 12 ++++++------ openerp/addons/base/ir/ir_qweb.py | 5 +---- setup.cfg | 1 - setup/package.dfcentos | 1 - setup/package.dfdebian | 1 - setup/package.dfsrc | 1 - 7 files changed, 7 insertions(+), 15 deletions(-) diff --git a/debian/control b/debian/control index 19647396245..8964e6c52c3 100644 --- a/debian/control +++ b/debian/control @@ -15,7 +15,6 @@ Depends: ${misc:Depends}, adduser, node-less, - node-clean-css, postgresql-client, python, python-dateutil, diff --git a/doc/setup/install.rst b/doc/setup/install.rst index e74ce8345cc..41a8d3e2e4a 100644 --- a/doc/setup/install.rst +++ b/doc/setup/install.rst @@ -462,25 +462,25 @@ Source installation requires manually installing dependencies: $ apt-get install -y npm $ sudo ln -s /usr/bin/nodejs /usr/bin/node - Once npm is installed, use it to install less and less-plugin-clean-css: + Once npm is installed, use it to install less: .. code-block:: console - $ sudo npm install -g less less-plugin-clean-css + $ sudo npm install -g less - on OS X, install nodejs via your preferred package manager (homebrew_, - macports_) then install less and less-plugin-clean-css: + macports_) then install less: .. code-block:: console - $ sudo npm install -g less less-plugin-clean-css + $ sudo npm install -g less - on Windows, `install nodejs `_, reboot (to - update the :envvar:`PATH`) and install less and less-plugin-clean-css: + update the :envvar:`PATH`) and install less: .. code-block:: ps1 - C:\> npm install -g less less-plugin-clean-css + C:\> npm install -g less Running Odoo ------------ diff --git a/openerp/addons/base/ir/ir_qweb.py b/openerp/addons/base/ir/ir_qweb.py index 8450f468aea..5511298e746 100644 --- a/openerp/addons/base/ir/ir_qweb.py +++ b/openerp/addons/base/ir/ir_qweb.py @@ -1636,9 +1636,6 @@ class PreprocessedCSS(StylesheetAsset): self.html_url_format = '%%s/%s/%%s.css' % self.bundle.xmlid self.html_url_args = tuple(self.url.rsplit('/', 1)) - def minify(self): - return self.with_header() - def get_source(self): content = self.inline or self._fetch_content() return "/*! %s */\n%s" % (self.id, content) @@ -1688,7 +1685,7 @@ class LessStylesheetAsset(PreprocessedCSS): except IOError: lessc = 'lessc' lesspath = get_resource_path('web', 'static', 'lib', 'bootstrap', 'less') - return [lessc, '-', '--clean-css', '--no-js', '--no-color', '--include-path=%s' % lesspath] + return [lessc, '-', '--no-js', '--no-color', '--include-path=%s' % lesspath] def rjsmin(script): """ Minify js with a clever regex. diff --git a/setup.cfg b/setup.cfg index cc4ff5c2171..f4ff8868e67 100644 --- a/setup.cfg +++ b/setup.cfg @@ -6,7 +6,6 @@ requires = babel libxslt-python nodejs-less - nodejs-clean-css pychart pyparsing python-dateutil diff --git a/setup/package.dfcentos b/setup/package.dfcentos index 4b2a90647ef..cece5a4c339 100644 --- a/setup/package.dfcentos +++ b/setup/package.dfcentos @@ -10,7 +10,6 @@ RUN yum install -d 0 -e 0 epel-release -y && \ babel \ libxslt-python \ nodejs-less \ - nodejs-clean-css \ pychart \ pyparsing \ python-dateutil \ diff --git a/setup/package.dfdebian b/setup/package.dfdebian index 87ab5f285fd..a0f093091cb 100644 --- a/setup/package.dfdebian +++ b/setup/package.dfdebian @@ -18,7 +18,6 @@ RUN apt-get update -qq && \ apt-get install \ adduser \ node-less \ - node-clean-css \ postgresql \ postgresql-client \ python \ diff --git a/setup/package.dfsrc b/setup/package.dfsrc index e6544002990..73e4e6cd457 100644 --- a/setup/package.dfsrc +++ b/setup/package.dfsrc @@ -21,7 +21,6 @@ RUN apt-get update -qq && \ postgresql-client \ adduser \ node-less \ - node-clean-css \ libxml2-dev \ libxslt1-dev \ libldap2-dev \