1
0
Fork 0
VaultUI/webpack.config.js

119 lines
2.5 KiB
JavaScript
Raw Normal View History

2021-04-15 13:01:58 +01:00
const path = require('path');
const webpack = require('webpack');
2021-05-09 16:31:01 +01:00
var os = require("os");
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 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",
2022-01-11 13:16:08 +00:00
"safari": "11.1"
2021-05-16 13:21:54 +01:00
}
}
]
],
"plugins": [
["@babel/plugin-proposal-decorators", { "decoratorsBeforeExport": true }],
["@babel/plugin-proposal-class-properties"],
2022-01-11 13:16:08 +00:00
["@babel/transform-runtime"],
["@babel/plugin-syntax-import-assertions"]
2021-05-16 13:21:54 +01:00
]
};
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 = {
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'),
filename: 'bundle.js',
publicPath: '/',
2021-04-15 13:01:58 +01:00
},
2021-05-03 15:56:21 +01:00
stats: {
colors: true,
timings: true,
},
plugins: [
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-04-15 13:01:58 +01:00
devServer: {
2021-04-15 13:09:03 +01:00
open: process.env.BROWSER || "microsoft-edge-dev",
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-04-15 13:01:58 +01:00
module: {
rules: [
2022-01-11 13:16:08 +00:00
{
assert: { type: "css" },
loader: "css-loader",
options: {
exportType: "string",
},
},
2021-04-15 13:01:58 +01:00
{
test: /\.(sa|sc|c)ss$/,
use: [
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
};