Commit 2ad3279f1af243b5872319a96f73e583c5a550d4

Authored by DK
1 parent 9f7f5145

Minify JSON localization files on a build stage.

... ... @@ -128,7 +128,8 @@
128 128 "webpack-dev-server": "^1.15.1",
129 129 "webpack-hot-middleware": "^2.12.2",
130 130 "webpack-material-design-icons": "^0.1.0",
131   - "directory-tree": "^2.1.0"
  131 + "directory-tree": "^2.1.0",
  132 + "jsonminify": "^0.4.1"
132 133 },
133 134 "engine": "node >= 5.9.0",
134 135 "nyc": {
... ...
... ... @@ -21,6 +21,7 @@ const CopyWebpackPlugin = require('copy-webpack-plugin');
21 21 const webpack = require('webpack');
22 22 const path = require('path');
23 23 const dirTree = require('directory-tree');
  24 +const jsonminify = require("jsonminify");
24 25
25 26 const PUBLIC_RESOURCE_PATH = '/';
26 27
... ... @@ -55,8 +56,18 @@ module.exports = {
55 56 moment: "moment"
56 57 }),
57 58 new CopyWebpackPlugin([
58   - { from: './src/thingsboard.ico', to: 'thingsboard.ico' },
59   - { from: './src/app/locale', to: 'locale' }
  59 + {
  60 + from: './src/thingsboard.ico',
  61 + to: 'thingsboard.ico'
  62 + },
  63 + {
  64 + from: './src/app/locale',
  65 + to: 'locale',
  66 + ignore: [ '*.js' ],
  67 + transform: function(content, path) {
  68 + return Buffer.from(jsonminify(content.toString()));
  69 + }
  70 + }
60 71 ]),
61 72 new webpack.HotModuleReplacementPlugin(),
62 73 new HtmlWebpackPlugin({
... ...
... ... @@ -22,6 +22,7 @@ const CompressionPlugin = require('compression-webpack-plugin');
22 22 const webpack = require('webpack');
23 23 const path = require('path');
24 24 const dirTree = require('directory-tree');
  25 +const jsonminify = require("jsonminify");
25 26
26 27 const PUBLIC_RESOURCE_PATH = '/static/';
27 28
... ... @@ -53,8 +54,18 @@ module.exports = {
53 54 moment: "moment"
54 55 }),
55 56 new CopyWebpackPlugin([
56   - { from: './src/thingsboard.ico', to: 'thingsboard.ico'},
57   - { from: './src/app/locale', to: 'locale' }
  57 + {
  58 + from: './src/thingsboard.ico',
  59 + to: 'thingsboard.ico'
  60 + },
  61 + {
  62 + from: './src/app/locale',
  63 + to: 'locale',
  64 + ignore: [ '*.js' ],
  65 + transform: function(content, path) {
  66 + return Buffer.from(jsonminify(content.toString()));
  67 + }
  68 + }
58 69 ]),
59 70 new HtmlWebpackPlugin({
60 71 template: './src/index.html',
... ...