1
0
Fork 0
VaultUI/webpack.config.js

96 lines
2.1 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-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": {
"firefox": "60",
2021-05-16 13:47:28 +01:00
"chrome": "67"
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 = {
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',
2021-04-15 13:01:58 +01:00
},
2021-05-03 15:56:21 +01:00
stats: {
colors: true,
timings: true,
},
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-04-15 13:01:58 +01:00
devServer: {
2021-04-15 13:09:03 +01:00
open: process.env.BROWSER || "microsoft-edge-dev",
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: [
{
test: /\.(sa|sc|c)ss$/,
use: [
2021-04-18 11:28:55 +01:00
MiniCssExtractPlugin.loader,
"css-loader",
"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
],
},
};