2018-06-04 01:03:46 +00:00
|
|
|
const path = require('path');
|
2018-06-04 02:35:50 +00:00
|
|
|
const AssetsManifestPlugin = require('webpack-assets-manifest');
|
2019-02-10 03:43:11 +00:00
|
|
|
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
|
2019-06-10 00:29:10 +00:00
|
|
|
const TerserPlugin = require('terser-webpack-plugin');
|
2020-07-05 01:19:46 +00:00
|
|
|
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
|
2018-12-16 22:30:21 +00:00
|
|
|
|
2019-02-03 01:33:12 +00:00
|
|
|
const isProduction = process.env.NODE_ENV === 'production';
|
2018-06-04 01:03:46 +00:00
|
|
|
|
2018-03-31 04:58:38 +00:00
|
|
|
module.exports = {
|
2019-06-10 00:29:10 +00:00
|
|
|
cache: true,
|
2019-02-03 02:49:51 +00:00
|
|
|
target: 'web',
|
2018-06-04 03:34:30 +00:00
|
|
|
mode: process.env.NODE_ENV,
|
2020-07-05 01:19:46 +00:00
|
|
|
devtool: isProduction ? false : (process.env.DEVTOOL || 'eval-source-map'),
|
2018-06-04 00:40:35 +00:00
|
|
|
performance: {
|
|
|
|
hints: false,
|
|
|
|
},
|
2020-07-05 01:19:46 +00:00
|
|
|
entry: ['react-hot-loader/patch', './resources/scripts/index.tsx'],
|
2018-03-31 04:58:38 +00:00
|
|
|
output: {
|
2020-07-05 03:54:33 +00:00
|
|
|
path: path.join(__dirname, '/public/assets'),
|
2019-02-03 02:25:33 +00:00
|
|
|
filename: isProduction ? 'bundle.[chunkhash:8].js' : 'bundle.[hash:8].js',
|
|
|
|
chunkFilename: isProduction ? '[name].[chunkhash:8].js' : '[name].[hash:8].js',
|
2022-02-12 18:18:08 +00:00
|
|
|
publicPath: (process.env.WEBPACK_PUBLIC_PATH || '/assets/'),
|
2018-06-04 01:46:27 +00:00
|
|
|
crossOriginLoading: 'anonymous',
|
2018-03-31 04:58:38 +00:00
|
|
|
},
|
|
|
|
module: {
|
|
|
|
rules: [
|
2019-02-03 02:25:33 +00:00
|
|
|
{
|
2020-07-05 03:54:33 +00:00
|
|
|
test: /\.tsx?$/,
|
2018-12-16 22:30:21 +00:00
|
|
|
exclude: /node_modules/,
|
2020-07-03 20:55:33 +00:00
|
|
|
loader: 'babel-loader',
|
2018-03-31 04:58:38 +00:00
|
|
|
},
|
2018-05-28 21:16:03 +00:00
|
|
|
{
|
2018-06-04 01:46:27 +00:00
|
|
|
test: /\.css$/,
|
2020-07-05 01:19:46 +00:00
|
|
|
use: [ 'style-loader', 'css-loader' ],
|
2018-12-16 22:30:21 +00:00
|
|
|
},
|
|
|
|
{
|
2020-07-05 03:54:33 +00:00
|
|
|
test: /\.(png|jp(e?)g|gif)$/,
|
2018-12-16 22:30:21 +00:00
|
|
|
loader: 'file-loader',
|
|
|
|
options: {
|
2020-07-05 03:54:33 +00:00
|
|
|
name: 'images/[name].[hash:8].[ext]',
|
2018-12-16 22:30:21 +00:00
|
|
|
},
|
|
|
|
},
|
2020-07-03 20:55:33 +00:00
|
|
|
{
|
2020-07-05 01:19:46 +00:00
|
|
|
test: /\.svg$/,
|
|
|
|
loader: 'svg-url-loader',
|
2020-07-05 03:54:33 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.js$/,
|
|
|
|
enforce: 'pre',
|
|
|
|
loader: 'source-map-loader',
|
2020-07-03 20:55:33 +00:00
|
|
|
}
|
2018-12-16 22:30:21 +00:00
|
|
|
],
|
2018-03-31 04:58:38 +00:00
|
|
|
},
|
2020-07-05 03:54:33 +00: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-31 04:58:38 +00:00
|
|
|
resolve: {
|
2019-06-10 00:29:10 +00:00
|
|
|
extensions: ['.ts', '.tsx', '.js', '.json'],
|
2018-03-31 04:58:38 +00:00
|
|
|
alias: {
|
2020-07-05 03:54:33 +00:00
|
|
|
'@': path.join(__dirname, '/resources/scripts'),
|
2022-02-13 18:00:52 +00:00
|
|
|
'@feature': path.join(__dirname, '/resources/scripts/components/server/features'),
|
2021-07-09 18:58:06 +00:00
|
|
|
'react-dom': '@hot-loader/react-dom',
|
2018-03-31 04:58:38 +00:00
|
|
|
},
|
2018-06-04 03:34:30 +00:00
|
|
|
symlinks: false,
|
2018-03-31 04:58:38 +00:00
|
|
|
},
|
2020-07-05 04:57:35 +00: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-05 01:19:46 +00:00
|
|
|
plugins: [
|
|
|
|
new AssetsManifestPlugin({ writeToDisk: true, publicPath: true, integrity: true, integrityHashes: ['sha384'] }),
|
2021-05-08 17:37:18 +00:00
|
|
|
new ForkTsCheckerWebpackPlugin({
|
|
|
|
typescript: {
|
|
|
|
mode: 'write-references',
|
|
|
|
diagnosticOptions: {
|
|
|
|
semantic: true,
|
|
|
|
syntactic: true,
|
|
|
|
},
|
2020-07-05 01:19:46 +00:00
|
|
|
},
|
2021-05-08 17:37:18 +00:00
|
|
|
eslint: isProduction ? undefined : {
|
|
|
|
files: `${path.join(__dirname, '/resources/scripts')}/**/*.{ts,tsx}`,
|
|
|
|
}
|
2020-07-12 17:43:37 +00:00
|
|
|
}),
|
2020-07-05 04:46:49 +00:00
|
|
|
process.env.ANALYZE_BUNDLE ? new BundleAnalyzerPlugin({
|
|
|
|
analyzerHost: '0.0.0.0',
|
|
|
|
analyzerPort: 8081,
|
|
|
|
}) : null
|
2020-07-05 01:19:46 +00:00
|
|
|
].filter(p => p),
|
2019-02-03 01:33:12 +00:00
|
|
|
optimization: {
|
2020-07-05 01:19:46 +00:00
|
|
|
usedExports: true,
|
|
|
|
sideEffects: false,
|
|
|
|
runtimeChunk: false,
|
|
|
|
removeEmptyChunks: true,
|
2019-07-17 04:43:11 +00:00
|
|
|
minimize: isProduction,
|
2019-06-10 00:29:10 +00:00
|
|
|
minimizer: [
|
|
|
|
new TerserPlugin({
|
2020-12-26 18:41:25 +00:00
|
|
|
cache: isProduction,
|
2019-02-03 01:33:12 +00:00
|
|
|
parallel: true,
|
2020-07-05 01:19:46 +00:00
|
|
|
extractComments: false,
|
2019-06-10 00:29:10 +00:00
|
|
|
terserOptions: {
|
|
|
|
mangle: true,
|
2019-02-03 01:33:12 +00:00
|
|
|
output: {
|
|
|
|
comments: false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
},
|
2019-09-18 04:05:20 +00:00
|
|
|
watchOptions: {
|
2020-03-23 01:15:38 +00:00
|
|
|
poll: 1000,
|
2019-09-18 04:05:20 +00:00
|
|
|
ignored: /node_modules/,
|
|
|
|
},
|
2019-02-03 01:33:12 +00:00
|
|
|
devServer: {
|
2020-07-05 01:19:46 +00:00
|
|
|
compress: true,
|
2020-07-05 03:54:33 +00:00
|
|
|
contentBase: path.join(__dirname, '/public'),
|
2022-02-12 18:18:08 +00:00
|
|
|
publicPath: process.env.WEBPACK_PUBLIC_PATH || '/assets/',
|
2019-02-03 01:33:12 +00:00
|
|
|
allowedHosts: [
|
|
|
|
'.pterodactyl.test',
|
|
|
|
],
|
|
|
|
headers: {
|
|
|
|
'Access-Control-Allow-Origin': '*',
|
2018-12-16 22:30:21 +00:00
|
|
|
},
|
|
|
|
},
|
2018-03-31 04:58:38 +00:00
|
|
|
};
|