2025-12-20 15:55:13 -08:00
|
|
|
const path = require('node:path');
|
2022-06-11 14:04:09 -04:00
|
|
|
const webpack = require('webpack');
|
2025-12-20 15:55:13 -08:00
|
|
|
const { WebpackAssetsManifest } = require('webpack-assets-manifest');
|
2019-06-09 17:29:10 -07:00
|
|
|
const TerserPlugin = require('terser-webpack-plugin');
|
2018-12-16 14:30:21 -08:00
|
|
|
|
2019-02-02 17:33:12 -08:00
|
|
|
const isProduction = process.env.NODE_ENV === 'production';
|
2018-06-03 18:03:46 -07:00
|
|
|
|
2018-03-30 23:58:38 -05:00
|
|
|
module.exports = {
|
2019-06-09 17:29:10 -07:00
|
|
|
cache: true,
|
2019-02-02 18:49:51 -08:00
|
|
|
target: 'web',
|
2025-12-20 15:55:13 -08:00
|
|
|
mode: isProduction ? 'production' : 'development',
|
|
|
|
|
devtool: process.env.DEVTOOL || (isProduction ? false : 'eval-source-map'),
|
2018-06-03 17:40:35 -07:00
|
|
|
performance: {
|
|
|
|
|
hints: false,
|
|
|
|
|
},
|
2020-07-04 18:19:46 -07:00
|
|
|
entry: ['react-hot-loader/patch', './resources/scripts/index.tsx'],
|
2018-03-30 23:58:38 -05:00
|
|
|
output: {
|
2020-07-04 20:54:33 -07:00
|
|
|
path: path.join(__dirname, '/public/assets'),
|
2025-12-20 15:55:13 -08:00
|
|
|
filename: isProduction ? 'bundle.[chunkhash:8].js' : 'bundle.[fullhash:8].js',
|
|
|
|
|
chunkFilename: isProduction ? '[name].[chunkhash:8].js' : '[name].[fullhash:8].js',
|
2025-12-24 17:39:26 -08:00
|
|
|
publicPath: process.env.WEBPACK_PUBLIC_PATH || '/assets/',
|
2018-06-03 18:46:27 -07:00
|
|
|
crossOriginLoading: 'anonymous',
|
2018-03-30 23:58:38 -05:00
|
|
|
},
|
|
|
|
|
module: {
|
|
|
|
|
rules: [
|
2019-02-02 18:25:33 -08:00
|
|
|
{
|
2020-07-04 20:54:33 -07:00
|
|
|
test: /\.tsx?$/,
|
2022-06-05 14:34:29 -04:00
|
|
|
exclude: /node_modules|\.spec\.tsx?$/,
|
2020-07-03 13:55:33 -07:00
|
|
|
loader: 'babel-loader',
|
2018-03-30 23:58:38 -05:00
|
|
|
},
|
2022-06-05 18:27:54 -04:00
|
|
|
{
|
|
|
|
|
test: /\.mjs$/,
|
|
|
|
|
include: /node_modules/,
|
|
|
|
|
type: 'javascript/auto',
|
|
|
|
|
},
|
2018-05-28 23:16:03 +02:00
|
|
|
{
|
2018-06-03 18:46:27 -07:00
|
|
|
test: /\.css$/,
|
2022-06-05 14:34:29 -04:00
|
|
|
use: [
|
|
|
|
|
{ loader: 'style-loader' },
|
|
|
|
|
{
|
|
|
|
|
loader: 'css-loader',
|
|
|
|
|
options: {
|
|
|
|
|
modules: {
|
|
|
|
|
auto: true,
|
2025-12-20 15:55:13 -08:00
|
|
|
// https://github.com/webpack/css-loader/blob/main/CHANGELOG.md#700-2024-04-04
|
|
|
|
|
namedExport: false,
|
|
|
|
|
exportLocalsConvention: 'as-is',
|
2022-06-05 14:34:29 -04:00
|
|
|
localIdentName: isProduction ? '[name]_[hash:base64:8]' : '[path][name]__[local]',
|
|
|
|
|
localIdentContext: path.join(__dirname, 'resources/scripts/components'),
|
|
|
|
|
},
|
|
|
|
|
sourceMap: !isProduction,
|
|
|
|
|
importLoaders: 1,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
loader: 'postcss-loader',
|
|
|
|
|
options: { sourceMap: !isProduction },
|
|
|
|
|
},
|
|
|
|
|
],
|
2018-12-16 14:30:21 -08:00
|
|
|
},
|
|
|
|
|
{
|
2020-07-04 20:54:33 -07:00
|
|
|
test: /\.(png|jp(e?)g|gif)$/,
|
2018-12-16 14:30:21 -08:00
|
|
|
loader: 'file-loader',
|
|
|
|
|
options: {
|
2020-07-04 20:54:33 -07:00
|
|
|
name: 'images/[name].[hash:8].[ext]',
|
2018-12-16 14:30:21 -08:00
|
|
|
},
|
|
|
|
|
},
|
2025-12-20 16:37:54 -08:00
|
|
|
{
|
|
|
|
|
test: /\.(woff|woff2)$/i,
|
|
|
|
|
type: 'asset/resource',
|
|
|
|
|
},
|
2020-07-03 13:55:33 -07:00
|
|
|
{
|
2020-07-04 18:19:46 -07:00
|
|
|
test: /\.svg$/,
|
|
|
|
|
loader: 'svg-url-loader',
|
2020-07-04 20:54:33 -07:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
test: /\.js$/,
|
|
|
|
|
enforce: 'pre',
|
|
|
|
|
loader: 'source-map-loader',
|
2025-12-24 17:39:26 -08:00
|
|
|
},
|
2018-12-16 14:30:21 -08:00
|
|
|
],
|
2018-03-30 23:58:38 -05:00
|
|
|
},
|
2020-07-04 20:54:33 -07:00
|
|
|
stats: {
|
|
|
|
|
// Ignore warnings emitted by "source-map-loader" when trying to parse source maps from
|
|
|
|
|
// JS plugins we use, namely brace editor.
|
|
|
|
|
warningsFilter: [/Failed to parse source map/],
|
|
|
|
|
},
|
2018-03-30 23:58:38 -05:00
|
|
|
resolve: {
|
2019-06-09 17:29:10 -07:00
|
|
|
extensions: ['.ts', '.tsx', '.js', '.json'],
|
2018-03-30 23:58:38 -05:00
|
|
|
alias: {
|
2020-07-04 20:54:33 -07:00
|
|
|
'@': path.join(__dirname, '/resources/scripts'),
|
2022-05-07 16:52:58 -04:00
|
|
|
'@definitions': path.join(__dirname, '/resources/scripts/api/definitions'),
|
2020-11-02 20:52:41 -08:00
|
|
|
'@feature': path.join(__dirname, '/resources/scripts/components/server/features'),
|
2018-03-30 23:58:38 -05:00
|
|
|
},
|
2018-06-03 20:34:30 -07:00
|
|
|
symlinks: false,
|
2018-03-30 23:58:38 -05:00
|
|
|
},
|
2020-07-04 21:57:35 -07:00
|
|
|
externals: {
|
|
|
|
|
// Mark moment as an external to exclude it from the Chart.js build since we don't need to use
|
|
|
|
|
// it for anything.
|
|
|
|
|
moment: 'moment',
|
|
|
|
|
},
|
2020-07-04 18:19:46 -07:00
|
|
|
plugins: [
|
2022-06-11 14:04:09 -04:00
|
|
|
new webpack.EnvironmentPlugin({
|
2025-12-20 15:55:13 -08:00
|
|
|
NODE_ENV: process.env.NODE_ENV || 'development',
|
2022-06-11 14:04:09 -04:00
|
|
|
DEBUG: process.env.NODE_ENV !== 'production',
|
|
|
|
|
WEBPACK_BUILD_HASH: Date.now().toString(16),
|
|
|
|
|
}),
|
2025-12-24 17:39:26 -08:00
|
|
|
new WebpackAssetsManifest({
|
|
|
|
|
output: 'manifest.json',
|
|
|
|
|
writeToDisk: true,
|
|
|
|
|
publicPath: true,
|
|
|
|
|
integrity: true,
|
|
|
|
|
integrityHashes: ['sha384'],
|
|
|
|
|
}),
|
2025-12-20 15:55:13 -08:00
|
|
|
],
|
2019-02-02 17:33:12 -08:00
|
|
|
optimization: {
|
2020-07-04 18:19:46 -07:00
|
|
|
usedExports: true,
|
|
|
|
|
sideEffects: false,
|
|
|
|
|
runtimeChunk: false,
|
|
|
|
|
removeEmptyChunks: true,
|
2019-07-16 21:43:11 -07:00
|
|
|
minimize: isProduction,
|
2019-06-09 17:29:10 -07:00
|
|
|
minimizer: [
|
|
|
|
|
new TerserPlugin({
|
2019-02-02 17:33:12 -08:00
|
|
|
parallel: true,
|
2020-07-04 18:19:46 -07:00
|
|
|
extractComments: false,
|
2019-06-09 17:29:10 -07:00
|
|
|
terserOptions: {
|
|
|
|
|
mangle: true,
|
2019-02-02 17:33:12 -08:00
|
|
|
output: {
|
|
|
|
|
comments: false,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}),
|
|
|
|
|
],
|
|
|
|
|
},
|
2019-09-17 21:05:20 -07:00
|
|
|
watchOptions: {
|
2020-03-22 18:15:38 -07:00
|
|
|
poll: 1000,
|
2019-09-17 21:05:20 -07:00
|
|
|
ignored: /node_modules/,
|
|
|
|
|
},
|
2019-02-02 17:33:12 -08:00
|
|
|
devServer: {
|
2020-07-04 18:19:46 -07:00
|
|
|
compress: true,
|
2025-12-20 15:55:13 -08:00
|
|
|
port: 5173,
|
2025-12-24 17:39:26 -08:00
|
|
|
server: {
|
|
|
|
|
type: 'https',
|
|
|
|
|
options: process.env.USE_LOCAL_CERTS
|
|
|
|
|
? {
|
|
|
|
|
ca: path.join(__dirname, '../../docker/certificates/root_ca.pem'),
|
|
|
|
|
cert: path.join(__dirname, '../../docker/certificates/pterodactyl.test.pem'),
|
|
|
|
|
key: path.join(__dirname, '../../docker/certificates/pterodactyl.test-key.pem'),
|
|
|
|
|
}
|
|
|
|
|
: undefined,
|
|
|
|
|
},
|
2025-12-20 15:55:13 -08:00
|
|
|
static: {
|
|
|
|
|
directory: path.join(__dirname, '/public'),
|
|
|
|
|
publicPath: process.env.WEBPACK_PUBLIC_PATH || '/assets/',
|
|
|
|
|
},
|
2025-12-24 17:39:26 -08:00
|
|
|
allowedHosts: ['.pterodactyl.test'],
|
2019-02-02 17:33:12 -08:00
|
|
|
headers: {
|
|
|
|
|
'Access-Control-Allow-Origin': '*',
|
2018-12-16 14:30:21 -08:00
|
|
|
},
|
|
|
|
|
},
|
2018-03-30 23:58:38 -05:00
|
|
|
};
|