gamesshop/webpack.config.js

102 lines
2.8 KiB
JavaScript
Raw Normal View History

2024-06-30 12:41:33 +00:00
const MiniCssExtractPlugin = require('mini-css-extract-plugin'),
Path = require('path'),
AssetsPlugin = require('assets-webpack-plugin'),
CopyPlugin = require('copy-webpack-plugin');
2024-07-05 14:50:53 +00:00
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
2024-06-30 12:41:33 +00:00
const PUBLIC_FOLDER = Path.resolve(__dirname, 'public'),
SOURCE_FOLDER = Path.resolve(__dirname, 'src'),
JS_FOLDER = Path.resolve(SOURCE_FOLDER, 'js'),
CSS_FOLDER = Path.resolve(SOURCE_FOLDER, 'css'),
PHP_FOLDER = Path.resolve(SOURCE_FOLDER, 'php');
const PROD = false;
const INDEX_PATH = Path.resolve(PHP_FOLDER, PROD ? 'index.prod.php' : 'index.dev.php');
module.exports = {
plugins: [
new AssetsPlugin({
filename: 'file-index.json',
path: SOURCE_FOLDER,
includeAllFileTypes: false,
entrypoints: true,
removeFullPathAutoPrefix: true
}),
new MiniCssExtractPlugin({
filename: 'css/[name].css'
}),
new CopyPlugin({
patterns: [
{
from: INDEX_PATH,
to: PUBLIC_FOLDER + '/index.php'
},
]
})
],
mode: PROD ? 'production' : 'development',
devtool: 'source-map',
optimization: {
runtimeChunk: "single",
2024-07-05 14:50:53 +00:00
minimize: true,
minimizer: [
new CssMinimizerPlugin()
],
2024-06-30 12:41:33 +00:00
splitChunks: {
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name: 'vendors',
chunks: 'all',
},
common: {
test: /[\\/]common[\\/]/,
name: 'common',
chunks: 'all'
}
},
},
},
module: {
rules: [
{
test: /\.css$/i,
use: [
MiniCssExtractPlugin.loader,
'css-loader'
],
},
{
test: /\.scss$/i,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
'resolve-url-loader',
"sass-loader"
]
},
{
test: /\.ts$/i,
use: 'ts-loader',
exclude: /node_modules/,
},
{
test: /\.(woff|woff2|eot|ttf|otf|gif|svg)$/i,
type: 'asset/resource',
}
],
},
resolve: {
extensions: ['.js', '.ts'],
},
entry: {
2024-07-05 14:50:53 +00:00
index: JS_FOLDER + "/pages/index",
'admin/accounts': JS_FOLDER + "/pages/admin/accounts",
2024-07-06 18:49:50 +00:00
keys: JS_FOLDER + "/pages/keys/index",
2024-06-30 12:41:33 +00:00
},
output: {
path: PUBLIC_FOLDER,
filename: 'js/[name].js'
}
}