mirror of
https://github.com/aleleba/create-react-component-library.git
synced 2026-11-21 21:44:25 -06:00
Update dependencies with npm-check-updates (Cypress 16, dotenv 18, jest-dom 7, Storybook 10.6, Babel 8.0.7, React 19.3) and run npm audit fix. TypeScript and ESLint stay on their current major because ts-jest, typescript-eslint and eslint-plugin-react do not support TypeScript 7 or ESLint 10 yet. Fix lint errors surfaced by the update and document the final versions in the README.
96 lines
2.2 KiB
TypeScript
96 lines
2.2 KiB
TypeScript
import path from 'path';
|
|
import webpack from 'webpack';
|
|
import * as dotenv from 'dotenv';
|
|
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
|
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
|
|
import { CleanWebpackPlugin } from 'clean-webpack-plugin';
|
|
import CssMinimizerPlugin from 'css-minimizer-webpack-plugin';
|
|
import TerserPlugin from 'terser-webpack-plugin';
|
|
import ESLintPlugin from 'eslint-webpack-plugin';
|
|
import { resolveTsAliases } from 'resolve-ts-aliases';
|
|
|
|
const dotEnvToParse = dotenv.config();
|
|
const externalCss = process.env.EXTERNAL_CSS === 'true' ? true : false;
|
|
const externalCssName = process.env.EXTERNAL_CSS_NAME ? process.env.EXTERNAL_CSS_NAME : 'index.css';
|
|
const alias = resolveTsAliases(path.resolve('tsconfig.json'));
|
|
|
|
export default {
|
|
entry: './src/components/index.tsx',
|
|
resolve: {
|
|
extensions: ['.js', '.jsx','.ts','.tsx', '.json'],
|
|
alias,
|
|
},
|
|
mode: 'development',
|
|
output: {
|
|
path: path.resolve('dist'),
|
|
},
|
|
target: 'web',
|
|
plugins: [
|
|
new CleanWebpackPlugin(),
|
|
...(externalCss === true ? [
|
|
new MiniCssExtractPlugin({
|
|
filename: externalCssName,
|
|
}),
|
|
] : []),
|
|
new webpack.DefinePlugin({
|
|
'process.env': JSON.stringify(dotEnvToParse.parsed),
|
|
}),
|
|
new ESLintPlugin(),
|
|
new HtmlWebpackPlugin({
|
|
template: path.join('public', 'index.html'),
|
|
}),
|
|
new webpack.ProvidePlugin({
|
|
React: 'react',
|
|
}),
|
|
],
|
|
module: {
|
|
rules: [
|
|
{
|
|
test: /\.(ts|tsx)$/,
|
|
exclude: /node_modules/,
|
|
use: {
|
|
loader: 'ts-loader',
|
|
options: { configFile: 'tsconfig.cy.json' },
|
|
},
|
|
},
|
|
{
|
|
test: /\.(js|jsx)$/,
|
|
exclude: /node_modules/,
|
|
use: 'babel-loader',
|
|
},
|
|
{
|
|
test: /\.(css|sass|scss)$/,
|
|
use: [
|
|
externalCss === true ? MiniCssExtractPlugin.loader : 'style-loader',
|
|
{
|
|
loader: 'css-loader',
|
|
options: {
|
|
modules: {
|
|
namedExport: false,
|
|
exportLocalsConvention: 'as-is',
|
|
auto: /\.module\.\w+$/i,
|
|
}
|
|
},
|
|
},
|
|
'sass-loader',
|
|
],
|
|
},
|
|
{
|
|
test: /\.(ttf|otf|eot|woff|woff2)$/,
|
|
loader: 'url-loader',
|
|
options: {
|
|
name: 'assets/fonts/[name].[ext]',
|
|
esModule: false,
|
|
},
|
|
},
|
|
]
|
|
},
|
|
optimization: {
|
|
minimize: true,
|
|
minimizer: [
|
|
new CssMinimizerPlugin(),
|
|
new TerserPlugin(),
|
|
],
|
|
},
|
|
};
|