2021-04-15 13:01:58 +01:00
|
|
|
const path = require('path');
|
2021-05-09 16:15:51 +01:00
|
|
|
const webpack = require('webpack');
|
2021-05-09 16:31:01 +01:00
|
|
|
var os = require("os");
|
2021-05-09 16:15:51 +01:00
|
|
|
|
2021-05-30 09:25:53 +01:00
|
|
|
const TerserPlugin = require("terser-webpack-plugin");
|
|
|
|
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
|
2021-04-15 13:01:58 +01:00
|
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
|
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
2021-05-09 16:31:01 +01:00
|
|
|
const { GitRevisionPlugin } = require('git-revision-webpack-plugin');
|
|
|
|
const gitRevisionPlugin = new GitRevisionPlugin();
|
|
|
|
|
2021-05-16 13:21:54 +01:00
|
|
|
var babelOptions = {
|
|
|
|
"presets": [
|
|
|
|
[
|
|
|
|
"@babel/preset-env",
|
|
|
|
{
|
|
|
|
"corejs": { "version": 3 },
|
|
|
|
"useBuiltIns": "usage",
|
|
|
|
"targets": {
|
2021-05-30 09:28:42 +01:00
|
|
|
"firefox": "78",
|
2021-06-13 20:21:16 +01:00
|
|
|
"chrome": "84",
|
|
|
|
"safari": "11.1"
|
|
|
|
|
2021-05-16 13:21:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
],
|
|
|
|
"plugins": [
|
|
|
|
["@babel/plugin-proposal-decorators", { "decoratorsBeforeExport": true }],
|
|
|
|
["@babel/plugin-proposal-class-properties"],
|
|
|
|
["@babel/transform-runtime"]
|
|
|
|
]
|
|
|
|
};
|
2021-04-15 13:01:58 +01:00
|
|
|
|
2021-05-09 16:31:01 +01:00
|
|
|
let commitHash = gitRevisionPlugin.commithash();
|
|
|
|
|
2021-04-15 13:01:58 +01:00
|
|
|
module.exports = {
|
2021-05-18 11:10:47 +01:00
|
|
|
mode: "production",
|
|
|
|
cache: false,
|
2021-05-24 09:48:13 +01:00
|
|
|
entry: './src/main.tsx',
|
2021-04-15 13:01:58 +01:00
|
|
|
output: {
|
|
|
|
path: path.resolve(__dirname, 'dist'),
|
2021-05-16 12:04:47 +01:00
|
|
|
filename: 'bundle.js',
|
2022-01-06 18:53:38 +00:00
|
|
|
publicPath: '/',
|
2021-04-15 13:01:58 +01:00
|
|
|
},
|
2021-05-03 15:56:21 +01:00
|
|
|
stats: {
|
|
|
|
colors: true,
|
|
|
|
timings: true,
|
|
|
|
},
|
2021-05-09 16:15:51 +01:00
|
|
|
plugins: [
|
|
|
|
new MiniCssExtractPlugin(),
|
|
|
|
new HtmlWebpackPlugin({ title: "VaultUI" }),
|
|
|
|
new webpack.DefinePlugin({
|
2021-05-16 13:21:54 +01:00
|
|
|
BUILD_STRING:
|
|
|
|
JSON.stringify(`Built At: ${new Date().toString()} by ${os.userInfo().username}@${os.hostname()} on commit ${commitHash}`),
|
2021-05-09 16:15:51 +01:00
|
|
|
})
|
|
|
|
],
|
2021-04-15 13:01:58 +01:00
|
|
|
devServer: {
|
2021-04-15 13:09:03 +01:00
|
|
|
open: process.env.BROWSER || "microsoft-edge-dev",
|
2022-01-06 18:53:38 +00:00
|
|
|
historyApiFallback: true,
|
2021-04-15 13:01:58 +01:00
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
modules: ['node_modules'],
|
2021-05-08 01:54:38 +01:00
|
|
|
extensions: ['.tsx', '.ts', '.js', ".mjs"],
|
2021-04-15 13:01:58 +01:00
|
|
|
},
|
2021-05-16 12:04:47 +01:00
|
|
|
|
2021-04-15 13:01:58 +01:00
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.(sa|sc|c)ss$/,
|
|
|
|
use: [
|
2021-04-18 11:28:55 +01:00
|
|
|
MiniCssExtractPlugin.loader,
|
2022-01-11 10:57:30 +00:00
|
|
|
{loader: "css-loader", options: {exportType: "string"}},
|
2021-04-18 11:28:55 +01:00
|
|
|
"sass-loader"
|
2021-04-15 13:01:58 +01:00
|
|
|
],
|
2021-04-18 11:28:55 +01:00
|
|
|
},
|
2021-05-16 13:30:31 +01:00
|
|
|
{
|
|
|
|
test: /\.ts(x?)$/,
|
|
|
|
exclude: /node_modules/,
|
|
|
|
use: [
|
|
|
|
{
|
|
|
|
loader: 'babel-loader',
|
|
|
|
options: babelOptions
|
|
|
|
},
|
|
|
|
{
|
|
|
|
loader: 'ts-loader'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.js$/,
|
|
|
|
exclude: /node_modules/,
|
|
|
|
use: [
|
|
|
|
{
|
|
|
|
loader: 'babel-loader',
|
|
|
|
options: babelOptions
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
2021-04-15 13:01:58 +01:00
|
|
|
],
|
|
|
|
},
|
2021-05-30 09:25:53 +01:00
|
|
|
|
|
|
|
optimization: {
|
|
|
|
minimize: true,
|
|
|
|
minimizer: [
|
|
|
|
`...`,
|
|
|
|
new TerserPlugin({
|
|
|
|
terserOptions: {
|
|
|
|
ecma: "2015"
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
new CssMinimizerPlugin(),
|
|
|
|
],
|
|
|
|
},
|
2021-06-13 20:21:16 +01:00
|
|
|
};
|