create-nextgen
Version:
A CLI tool to scaffold projects using the NextGen template.
78 lines (75 loc) • 1.99 kB
JavaScript
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const isProd = process.env.NODE_ENV === 'production';
module.exports = {
entry: path.resolve(__dirname, '..', './src/index.tsx'),
resolve: {
extensions: ['.js', '.jsx', '.ts', '.tsx'],
},
module: {
rules: [
{
test: /\.(ts|js)x?$/,
exclude: /node_modules/,
use: ['babel-loader'],
},
{
test: /\.module\.css$/,
use: [
isProd ? MiniCssExtractPlugin.loader : 'style-loader',
{
loader: 'css-loader',
options: {
modules: true,
},
},
],
},
{
test: /\.(css|scss)$/i,
exclude: /\.module\.css$/,
use: [isProd? MiniCssExtractPlugin.loader : 'style-loader', 'css-loader', 'sass-loader'],
},
{
test: /\.(ico|gif|png|jpg|jpeg)$/i,
type: 'asset/resource',
},
{
test: /\.(woff|woff2|eot|ttf|otf|svg)$/i,
type: 'asset/resource',
},
],
},
output: {
path: path.resolve(__dirname, '..', './build'),
filename: '[name].[contenthash].js',
chunkFilename: '[name].[contenthash].js',
clean: true,
},
optimization: {
splitChunks: {
chunks: 'all',
minSize: 20000,
maxSize: 40000,
automaticNameDelimiter: '-',
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name: 'vendors',
chunks: 'all',
},
},
},
},
plugins: [
new HtmlWebpackPlugin({
template: path.resolve(__dirname, '..', './public/index.html'),
}),
new CopyPlugin({
patterns: [{ from: 'public', to: 'build' }],
}),
new MiniCssExtractPlugin(),
],
}