|
|
|
@ -16,15 +16,14 @@ |
|
|
|
/* eslint-disable */ |
|
|
|
|
|
|
|
const HtmlWebpackPlugin = require('html-webpack-plugin'); |
|
|
|
const ExtractTextPlugin = require('extract-text-webpack-plugin'); |
|
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin'); |
|
|
|
const CopyWebpackPlugin = require('copy-webpack-plugin'); |
|
|
|
const CompressionPlugin = require('compression-webpack-plugin'); |
|
|
|
|
|
|
|
const webpack = require('webpack'); |
|
|
|
const path = require('path'); |
|
|
|
const dirTree = require('directory-tree'); |
|
|
|
const jsonminify = require("jsonminify"); |
|
|
|
const UglifyJsPlugin = require('uglifyjs-webpack-plugin'); |
|
|
|
const HappyPack = require('happypack'); |
|
|
|
|
|
|
|
const PUBLIC_RESOURCE_PATH = '/static/'; |
|
|
|
|
|
|
|
@ -35,9 +34,8 @@ dirTree('./src/app/locale/', {extensions:/\.json$/}, (item) => { |
|
|
|
langs.push(item.name.slice(item.name.lastIndexOf('-') + 1, -5)); |
|
|
|
}); |
|
|
|
|
|
|
|
var happyThreadPool = HappyPack.ThreadPool({ size: 3 }); |
|
|
|
|
|
|
|
module.exports = { |
|
|
|
mode: 'production', |
|
|
|
devtool: 'source-map', |
|
|
|
entry: [ |
|
|
|
'./src/app/app.js', |
|
|
|
@ -77,47 +75,21 @@ module.exports = { |
|
|
|
title: 'ThingsBoard', |
|
|
|
inject: 'body', |
|
|
|
}), |
|
|
|
new webpack.optimize.OccurrenceOrderPlugin(), |
|
|
|
new webpack.NoErrorsPlugin(), |
|
|
|
new webpack.optimize.DedupePlugin(), |
|
|
|
new webpack.optimize.CommonsChunkPlugin('vendor', 'vendor.[hash].js'), |
|
|
|
new ExtractTextPlugin('style.[contentHash].css', { |
|
|
|
allChunks: true, |
|
|
|
new MiniCssExtractPlugin({ |
|
|
|
filename: 'style.[contentHash].css' |
|
|
|
}), |
|
|
|
new webpack.DefinePlugin({ |
|
|
|
THINGSBOARD_VERSION: JSON.stringify(require('./package.json').version), |
|
|
|
'__DEVTOOLS__': false, |
|
|
|
'process.env': { |
|
|
|
NODE_ENV: JSON.stringify('production'), |
|
|
|
}, |
|
|
|
PUBLIC_PATH: PUBLIC_RESOURCE_PATH, |
|
|
|
SUPPORTED_LANGS: JSON.stringify(langs) |
|
|
|
}), |
|
|
|
new CompressionPlugin({ |
|
|
|
asset: "[path].gz[query]", |
|
|
|
filename: "[path].gz[query]", |
|
|
|
algorithm: "gzip", |
|
|
|
test: /\.js$|\.css$|\.svg$|\.ttf$|\.woff$|\.woff2$|\.eot$|\.json$/, |
|
|
|
threshold: 10240, |
|
|
|
minRatio: 0.8 |
|
|
|
}), |
|
|
|
new UglifyJsPlugin({ |
|
|
|
cache: true, |
|
|
|
parallel: true |
|
|
|
}), |
|
|
|
new HappyPack({ |
|
|
|
threadPool: happyThreadPool, |
|
|
|
id: 'cached-babel', |
|
|
|
loaders: ["babel-loader?cacheDirectory=true"] |
|
|
|
}), |
|
|
|
new HappyPack({ |
|
|
|
threadPool: happyThreadPool, |
|
|
|
id: 'eslint', |
|
|
|
loaders: ["eslint-loader?{parser: 'babel-eslint'}"] |
|
|
|
}), |
|
|
|
new HappyPack({ |
|
|
|
threadPool: happyThreadPool, |
|
|
|
id: 'ng-annotate-and-cached-babel-loader', |
|
|
|
loaders: ['ng-annotate', 'babel-loader?cacheDirectory=true'] |
|
|
|
}) |
|
|
|
], |
|
|
|
node: { |
|
|
|
@ -125,60 +97,131 @@ module.exports = { |
|
|
|
fs: "empty" |
|
|
|
}, |
|
|
|
module: { |
|
|
|
loaders: [ |
|
|
|
rules: [ |
|
|
|
{ |
|
|
|
test: /\.jsx$/, |
|
|
|
loader: 'happypack/loader?id=cached-babel', |
|
|
|
use: [ |
|
|
|
{ |
|
|
|
loader: 'babel-loader', |
|
|
|
options: { |
|
|
|
cacheDirectory: true |
|
|
|
} |
|
|
|
} |
|
|
|
], |
|
|
|
exclude: /node_modules/, |
|
|
|
include: __dirname, |
|
|
|
}, |
|
|
|
{ |
|
|
|
test: /\.js$/, |
|
|
|
loaders: ['happypack/loader?id=ng-annotate-and-cached-babel-loader'], |
|
|
|
use: [ |
|
|
|
{ |
|
|
|
loader: 'ng-annotate-loader', |
|
|
|
options: { |
|
|
|
ngAnnotate: 'ng-annotate-patched', |
|
|
|
es6: true, |
|
|
|
explicitOnly: false |
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
|
loader: 'babel-loader', |
|
|
|
options: { |
|
|
|
cacheDirectory: true |
|
|
|
} |
|
|
|
} |
|
|
|
], |
|
|
|
exclude: /node_modules/, |
|
|
|
include: __dirname, |
|
|
|
}, |
|
|
|
{ |
|
|
|
test: /\.js$/, |
|
|
|
loaders: ['happypack/loader?id=eslint'], |
|
|
|
// loader: "eslint-loader?{parser: 'babel-eslint'}",
|
|
|
|
use: [ |
|
|
|
{ |
|
|
|
loader: 'eslint-loader', |
|
|
|
options: { |
|
|
|
parser: 'babel-eslint' |
|
|
|
} |
|
|
|
} |
|
|
|
], |
|
|
|
exclude: /node_modules|vendor/, |
|
|
|
include: __dirname, |
|
|
|
}, |
|
|
|
{ |
|
|
|
test: /\.css$/, |
|
|
|
loader: ExtractTextPlugin.extract('style-loader', 'css-loader'), |
|
|
|
use: [ |
|
|
|
MiniCssExtractPlugin.loader, |
|
|
|
'css-loader' |
|
|
|
] |
|
|
|
}, |
|
|
|
{ |
|
|
|
test: /\.scss$/, |
|
|
|
loader: ExtractTextPlugin.extract('style-loader', 'css-loader!postcss-loader!sass-loader'), |
|
|
|
use: [ |
|
|
|
MiniCssExtractPlugin.loader, |
|
|
|
'css-loader', |
|
|
|
'postcss-loader', |
|
|
|
'sass-loader' |
|
|
|
] |
|
|
|
}, |
|
|
|
{ |
|
|
|
test: /\.less$/, |
|
|
|
loader: ExtractTextPlugin.extract('style-loader', 'css-loader!postcss-loader!less-loader'), |
|
|
|
use: [ |
|
|
|
MiniCssExtractPlugin.loader, |
|
|
|
'css-loader', |
|
|
|
'postcss-loader', |
|
|
|
'less-loader' |
|
|
|
] |
|
|
|
}, |
|
|
|
{ |
|
|
|
test: /\.tpl\.html$/, |
|
|
|
loader: 'ngtemplate?relativeTo=' + (path.resolve(__dirname, './src/app')) + '/!html!html-minifier-loader' |
|
|
|
use: [ |
|
|
|
{ |
|
|
|
loader: 'ngtemplate-loader', |
|
|
|
options: { |
|
|
|
relativeTo: path.resolve(__dirname, './src/app') |
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
|
loader: 'html-loader' |
|
|
|
}, |
|
|
|
{ |
|
|
|
loader: 'html-minifier-loader', |
|
|
|
options: { |
|
|
|
caseSensitive: true, |
|
|
|
removeComments: true, |
|
|
|
collapseWhitespace: false, |
|
|
|
preventAttributesEscaping: true, |
|
|
|
removeEmptyAttributes: false |
|
|
|
} |
|
|
|
} |
|
|
|
] |
|
|
|
}, |
|
|
|
{ |
|
|
|
test: /\.(svg)(\?v=[0-9]+\.[0-9]+\.[0-9]+)?$/, |
|
|
|
loader: 'url?limit=8192' |
|
|
|
use: [ |
|
|
|
{ |
|
|
|
loader: 'url-loader', |
|
|
|
options: { |
|
|
|
limit: 8192 |
|
|
|
} |
|
|
|
} |
|
|
|
] |
|
|
|
}, |
|
|
|
{ |
|
|
|
test: /\.(png|jpe?g|gif|woff|woff2|ttf|otf|eot|ico)(\?v=[0-9]+\.[0-9]+\.[0-9]+)?$/, |
|
|
|
loaders: [ |
|
|
|
'url?limit=8192', |
|
|
|
'img?minimize' |
|
|
|
use: [ |
|
|
|
{ |
|
|
|
loader: 'url-loader', |
|
|
|
options: { |
|
|
|
limit: 8192 |
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
|
loader: 'img-loader', |
|
|
|
options: { |
|
|
|
minimize: true |
|
|
|
} |
|
|
|
} |
|
|
|
] |
|
|
|
} |
|
|
|
], |
|
|
|
}, |
|
|
|
'html-minifier-loader': { |
|
|
|
caseSensitive: true, |
|
|
|
removeComments: true, |
|
|
|
collapseWhitespace: false, |
|
|
|
preventAttributesEscaping: true, |
|
|
|
removeEmptyAttributes: false |
|
|
|
} |
|
|
|
}; |
|
|
|
|