2016-12-01 11:40:28 +02:00
|
|
|
/*
|
2020-01-06 16:41:04 +02:00
|
|
|
* Copyright © 2016-2020 The Thingsboard Authors
|
2016-12-01 11:40:28 +02:00
|
|
|
*
|
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
|
*
|
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
*
|
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
|
* limitations under the License.
|
|
|
|
|
*/
|
|
|
|
|
/* eslint-disable */
|
|
|
|
|
|
|
|
|
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
2019-07-19 19:17:51 +03:00
|
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
2016-12-01 11:40:28 +02:00
|
|
|
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
2019-01-31 16:09:50 +02:00
|
|
|
const StyleLintPlugin = require('stylelint-webpack-plugin');
|
2018-09-06 19:34:43 +02:00
|
|
|
|
2016-12-01 11:40:28 +02:00
|
|
|
const webpack = require('webpack');
|
|
|
|
|
const path = require('path');
|
2018-07-14 21:19:23 +05:00
|
|
|
const dirTree = require('directory-tree');
|
2018-07-17 17:33:55 +05:00
|
|
|
const jsonminify = require("jsonminify");
|
2016-12-01 11:40:28 +02:00
|
|
|
|
2018-07-07 20:26:33 +05:00
|
|
|
const PUBLIC_RESOURCE_PATH = '/';
|
|
|
|
|
|
2018-07-14 21:19:23 +05:00
|
|
|
var langs = [];
|
|
|
|
|
dirTree('./src/app/locale/', {extensions:/\.json$/}, (item) => {
|
|
|
|
|
/* It is expected what the name of a locale file has the following format: */
|
|
|
|
|
/* 'locale.constant-LANG_CODE[_REGION_CODE].json', e.g. locale.constant-es.json or locale.constant-zh_CN.json*/
|
|
|
|
|
langs.push(item.name.slice(item.name.lastIndexOf('-') + 1, -5));
|
|
|
|
|
});
|
|
|
|
|
|
2016-12-01 11:40:28 +02:00
|
|
|
/* devtool: 'cheap-module-eval-source-map', */
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
2019-07-19 19:17:51 +03:00
|
|
|
mode: 'development',
|
2016-12-01 11:40:28 +02:00
|
|
|
devtool: 'source-map',
|
|
|
|
|
entry: [
|
|
|
|
|
'./src/app/app.js',
|
|
|
|
|
'webpack-hot-middleware/client?reload=true',
|
2017-02-22 21:34:28 +02:00
|
|
|
'webpack-material-design-icons'
|
2016-12-01 11:40:28 +02:00
|
|
|
],
|
|
|
|
|
output: {
|
|
|
|
|
path: path.resolve(__dirname, 'target/generated-resources/public/static'),
|
2018-07-07 20:26:33 +05:00
|
|
|
publicPath: PUBLIC_RESOURCE_PATH,
|
2016-12-01 11:40:28 +02:00
|
|
|
filename: 'bundle.js',
|
|
|
|
|
},
|
|
|
|
|
plugins: [
|
|
|
|
|
new webpack.ProvidePlugin({
|
|
|
|
|
$: "jquery",
|
|
|
|
|
jQuery: "jquery",
|
|
|
|
|
"window.jQuery": "jquery",
|
|
|
|
|
tinycolor: "tinycolor2",
|
|
|
|
|
tv4: "tv4",
|
|
|
|
|
moment: "moment"
|
|
|
|
|
}),
|
|
|
|
|
new CopyWebpackPlugin([
|
2018-07-17 17:33:55 +05:00
|
|
|
{
|
|
|
|
|
from: './src/thingsboard.ico',
|
|
|
|
|
to: 'thingsboard.ico'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
from: './src/app/locale',
|
|
|
|
|
to: 'locale',
|
|
|
|
|
ignore: [ '*.js' ],
|
|
|
|
|
transform: function(content, path) {
|
|
|
|
|
return Buffer.from(jsonminify(content.toString()));
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-12-01 11:40:28 +02:00
|
|
|
]),
|
|
|
|
|
new webpack.HotModuleReplacementPlugin(),
|
|
|
|
|
new HtmlWebpackPlugin({
|
|
|
|
|
template: './src/index.html',
|
|
|
|
|
filename: 'index.html',
|
2017-08-30 20:41:20 +03:00
|
|
|
title: 'ThingsBoard',
|
2016-12-01 11:40:28 +02:00
|
|
|
inject: 'body',
|
|
|
|
|
}),
|
2018-09-06 19:34:43 +02:00
|
|
|
new StyleLintPlugin(),
|
2019-07-19 19:17:51 +03:00
|
|
|
new MiniCssExtractPlugin({
|
|
|
|
|
filename: 'style.[contentHash].css'
|
2016-12-01 11:40:28 +02:00
|
|
|
}),
|
|
|
|
|
new webpack.DefinePlugin({
|
2017-05-03 14:24:26 +03:00
|
|
|
THINGSBOARD_VERSION: JSON.stringify(require('./package.json').version),
|
2016-12-01 11:40:28 +02:00
|
|
|
'__DEVTOOLS__': false,
|
2018-07-17 16:58:45 +03:00
|
|
|
PUBLIC_PATH: JSON.stringify(PUBLIC_RESOURCE_PATH),
|
2018-07-14 21:19:23 +05:00
|
|
|
SUPPORTED_LANGS: JSON.stringify(langs)
|
2019-01-31 16:09:50 +02:00
|
|
|
})
|
2016-12-01 11:40:28 +02:00
|
|
|
],
|
|
|
|
|
node: {
|
|
|
|
|
tls: "empty",
|
|
|
|
|
fs: "empty"
|
|
|
|
|
},
|
|
|
|
|
module: {
|
2019-07-19 19:17:51 +03:00
|
|
|
rules: [
|
2016-12-01 11:40:28 +02:00
|
|
|
{
|
|
|
|
|
test: /\.jsx$/,
|
2019-07-19 19:17:51 +03:00
|
|
|
use: [
|
|
|
|
|
{
|
|
|
|
|
loader: 'babel-loader',
|
|
|
|
|
options: {
|
|
|
|
|
cacheDirectory: true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
],
|
2016-12-01 11:40:28 +02:00
|
|
|
exclude: /node_modules/,
|
|
|
|
|
include: __dirname,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
test: /\.js$/,
|
2019-07-19 19:17:51 +03:00
|
|
|
use: [
|
|
|
|
|
{
|
|
|
|
|
loader: 'ng-annotate-loader',
|
|
|
|
|
options: {
|
|
|
|
|
ngAnnotate: 'ng-annotate-patched',
|
|
|
|
|
es6: true,
|
|
|
|
|
explicitOnly: false
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
loader: 'babel-loader',
|
|
|
|
|
options: {
|
|
|
|
|
cacheDirectory: true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
],
|
2016-12-01 11:40:28 +02:00
|
|
|
exclude: /node_modules/,
|
|
|
|
|
include: __dirname,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
test: /\.js$/,
|
2019-07-19 19:17:51 +03:00
|
|
|
use: [
|
|
|
|
|
{
|
|
|
|
|
loader: 'eslint-loader',
|
|
|
|
|
options: {
|
|
|
|
|
parser: 'babel-eslint'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
],
|
2016-12-01 11:40:28 +02:00
|
|
|
exclude: /node_modules|vendor/,
|
|
|
|
|
include: __dirname,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
test: /\.css$/,
|
2019-07-19 19:17:51 +03:00
|
|
|
use: [
|
|
|
|
|
MiniCssExtractPlugin.loader,
|
|
|
|
|
'css-loader'
|
|
|
|
|
]
|
2016-12-01 11:40:28 +02:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
test: /\.scss$/,
|
2019-07-19 19:17:51 +03:00
|
|
|
use: [
|
|
|
|
|
MiniCssExtractPlugin.loader,
|
|
|
|
|
'css-loader',
|
|
|
|
|
'postcss-loader',
|
|
|
|
|
'sass-loader'
|
|
|
|
|
]
|
2016-12-01 11:40:28 +02:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
test: /\.less$/,
|
2019-07-19 19:17:51 +03:00
|
|
|
use: [
|
|
|
|
|
MiniCssExtractPlugin.loader,
|
|
|
|
|
'css-loader',
|
|
|
|
|
'postcss-loader',
|
|
|
|
|
'less-loader'
|
|
|
|
|
]
|
2016-12-01 11:40:28 +02:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
test: /\.tpl\.html$/,
|
2019-07-19 19:17:51 +03:00
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
]
|
2016-12-01 11:40:28 +02:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
test: /\.(svg)(\?v=[0-9]+\.[0-9]+\.[0-9]+)?$/,
|
2019-07-19 19:17:51 +03:00
|
|
|
use: [
|
|
|
|
|
{
|
|
|
|
|
loader: 'url-loader',
|
|
|
|
|
options: {
|
|
|
|
|
limit: 8192
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
]
|
2016-12-01 11:40:28 +02:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
test: /\.(png|jpe?g|gif|woff|woff2|ttf|otf|eot|ico)(\?v=[0-9]+\.[0-9]+\.[0-9]+)?$/,
|
2019-07-19 19:17:51 +03:00
|
|
|
use: [
|
|
|
|
|
{
|
|
|
|
|
loader: 'url-loader',
|
|
|
|
|
options: {
|
|
|
|
|
limit: 8192
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
loader: 'img-loader',
|
|
|
|
|
options: {
|
|
|
|
|
minimize: true
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-12-01 11:40:28 +02:00
|
|
|
]
|
2018-07-07 20:26:33 +05:00
|
|
|
}
|
2016-12-01 11:40:28 +02:00
|
|
|
],
|
|
|
|
|
}
|
|
|
|
|
};
|