Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const plugins = [
['@babel/plugin-proposal-decorators', { legacy: true }],
['@babel/plugin-transform-runtime'],
['@babel/plugin-transform-modules-commonjs'],
['@babel/plugin-proposal-object-rest-spread'],
['@babel/plugin-proposal-object-rest-spread']
]

module.exports = {
Expand All @@ -12,20 +12,20 @@ module.exports = {
'@babel/preset-env',
{
targets: {
browsers: ['> 1%', 'last 2 versions', 'not ie <= 8'],
browsers: ['> 1%', 'last 2 versions', 'not ie <= 8']
},
modules: false,
useBuiltIns: 'entry',
corejs: 3,
},
corejs: 3
}
],
[
'@babel/preset-react',
{
runtime: 'automatic',
},
runtime: 'automatic'
}
],
'@babel/preset-typescript',
'@babel/preset-typescript'
],
compact: true,
comments: true,
Expand All @@ -35,7 +35,7 @@ module.exports = {
: plugins,
env: {
development: {
plugins: ['react-refresh/babel'],
},
},
plugins: ['react-refresh/babel']
}
}
}
92 changes: 46 additions & 46 deletions webpack/webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ switch (process.env.BUILD_GOAL) {

const config = {
entry: {
app: `${paths.src}/index.tsx`,
app: `${paths.src}/index.tsx`
},
output: {
path: paths.build,
Expand All @@ -47,7 +47,7 @@ const config = {
// library: '',
// libraryTarget: 'umd',
// chunkLoadingGlobal: '',
clean: true,
clean: true
// contentBase: path.join(__dirname, "public"), // 配置额外的静态文件内容的访问路径
},
resolve: {
Expand All @@ -62,17 +62,17 @@ const config = {
'@pages': path.resolve('./src/pages'),
'@routers': path.resolve('./src/routers'),
'@utils': path.resolve('./src/utils'),
'@theme': path.resolve('./src/theme'),
'@theme': path.resolve('./src/theme')
},
symlinks: false,
symlinks: false
},
stats: 'verbose', // 输出详细的构建信息
plugins: [
new Dotenv({
path: path.resolve(__dirname, '..', dotEnv),
path: path.resolve(__dirname, '..', dotEnv)
}),
codeInspectorPlugin({
bundler: 'webpack',
bundler: 'webpack'
}),
new HtmlWebpackPlugin({
title: isDev ? 'Pro React Dev' : 'Pro React Admin',
Expand All @@ -96,8 +96,8 @@ const config = {
minifyCSS: true,
minifyJS: true,
minifyURLs: true,
useShortDoctype: true,
},
useShortDoctype: true
}
}),
new AntdDayjsWebpackPlugin(),
new CaseSensitivePathsPlugin(),
Expand All @@ -111,16 +111,16 @@ const config = {
new NodePolyfillPlugin(),
new WebpackBar(),
new ForkTsCheckerWebpackPlugin({
async: true,
async: true
}),
new ESLintWebpackPlugin({
// 指定检查文件的根目录
context: path.resolve(__dirname, '../src'),
exclude: 'node_modules', // 默认值
cache: true, // 开启缓存
// 缓存目录
cacheLocation: path.resolve(__dirname, '../node_modules/.cache/.eslintcache'),
}),
cacheLocation: path.resolve(__dirname, '../node_modules/.cache/.eslintcache')
})
],
module: {
// 将缺失的导出提示成错误而不是警告
Expand All @@ -129,12 +129,12 @@ const config = {
{
test: /\.m?js$/,
resolve: {
fullySpecified: false,
},
fullySpecified: false
}
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader', 'postcss-loader'],
use: ['style-loader', 'css-loader', 'postcss-loader']
},
{
test: /\.less$/i,
Expand All @@ -151,10 +151,10 @@ const config = {
localIdentName: isDev ? '[path][name]__[local]--[hash:base64:5]' : '[local]--[hash:base64:5]',
localIdentContext: paths.src,
namedExport: false,
exportLocalsConvention: 'camelCase',
exportLocalsConvention: 'camelCase'
},
importLoaders: 2,
},
importLoaders: 2
}
},
{
loader: require.resolve('postcss-loader'),
Expand All @@ -168,18 +168,18 @@ const config = {
'postcss-preset-env',
{
autoprefixer: {
flexbox: 'no-2009',
flexbox: 'no-2009'
},
stage: 3,
},
stage: 3
}
],
'postcss-normalize',
],
'postcss-normalize'
]
},
sourceMap: true,
},
},
],
sourceMap: true
}
}
]
},
{
test: /\.(js|jsx|ts|tsx)$/,
Expand All @@ -189,62 +189,62 @@ const config = {
loader: 'esbuild-loader',
options: {
// loader: 'tsx',
target: 'es2020',
},
target: 'es2020'
}
},
{
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env', '@babel/preset-react'],
plugins: ['@babel/plugin-transform-object-rest-spread', '@babel/plugin-transform-runtime'],
},
},
],
plugins: ['@babel/plugin-transform-object-rest-spread', '@babel/plugin-transform-runtime']
}
}
]
},
{
test: /\.(png|jpe?g|gif|webp|eot|ttf|woff|woff2|mp4|mp3|mkv|pdf)$/i,
type: 'asset',
parser: {
// Conditions for converting to base64
dataUrlCondition: {
maxSize: 25 * 1024, // 25kb
},
maxSize: 25 * 1024 // 25kb
}
},
generator: {
filename: 'images/[contenthash][ext][query]',
},
filename: 'images/[contenthash][ext][query]'
}
},
{
test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
use: [
{
loader: 'babel-loader',
loader: 'babel-loader'
},
{
loader: '@svgr/webpack',
options: {
babel: false,
icon: true,
},
},
],
},
],
icon: true
}
}
]
}
]
},
stats: {
all: false,
errors: true,
warnings: true,
errorDetails: true,
moduleTrace: true, // 打印模块追踪信息,与--trace - warnings类似
excludeAssets: /node_modules/,
excludeAssets: /node_modules/
},
// 性能提示
performance: {
hints: isDev ? false : 'warning',
maxEntrypointSize: 512000,
maxAssetSize: 512000,
},
maxAssetSize: 512000
}
}

if (USE_ANALYZE) {
Expand Down
36 changes: 18 additions & 18 deletions webpack/webpack.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ const devWebpackConfig = merge(common, {
progress: true,
overlay: {
errors: true,
warnings: false,
},
warnings: false
}
},
static: {
directory: path.join(__dirname, '../public'),
directory: path.join(__dirname, '../public')
},
compress: true,
// open: true,
hot: true,
proxy: devProxy,
proxy: devProxy
},
// watch: true,
// watchOptions: {
Expand All @@ -46,17 +46,17 @@ const devWebpackConfig = merge(common, {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
plugins: [require.resolve('react-refresh/babel')].filter(Boolean),
},
},
],
},
],
plugins: [require.resolve('react-refresh/babel')].filter(Boolean)
}
}
]
}
]
},
plugins: [
new ReactRefreshWebpackPlugin({
overlay: false,
}),
overlay: false
})
// new webpack.debug.ProfilingPlugin({
// outputPath: path.join(__dirname, 'profiling/profileEvents.json'),
// }),
Expand All @@ -71,20 +71,20 @@ const devWebpackConfig = merge(common, {
test: /[\\/]node_modules[\\/]/,
name: 'vendors',
chunks: 'all',
priority: 10,
},
},
priority: 10
}
}
},
minimize: false,
concatenateModules: false,
usedExports: false,
},
usedExports: false
}
})
module.exports = new Promise((resolve, reject) => {
portfinder.getPort(
{
port: 8080, // 默认8080端口,若被占用,重复+1,直到找到可用端口或到stopPort才停止
stopPort: 65535, // maximum port
stopPort: 65535 // maximum port
},
(err, port) => {
if (err) {
Expand Down
Loading
Loading