build: fine tune swc config (#8384)
1. only run react related swc transforms for tsx files 2. exclude ts from ReactRefreshWebpackPlugin
This commit is contained in:
@@ -251,7 +251,33 @@ export const createConfiguration: (
|
|||||||
{
|
{
|
||||||
oneOf: [
|
oneOf: [
|
||||||
{
|
{
|
||||||
test: /\.tsx?$/,
|
test: /\.ts$/,
|
||||||
|
exclude: /node_modules/,
|
||||||
|
loader: 'swc-loader',
|
||||||
|
options: {
|
||||||
|
// https://swc.rs/docs/configuring-swc/
|
||||||
|
jsc: {
|
||||||
|
preserveAllComments: true,
|
||||||
|
parser: {
|
||||||
|
syntax: 'typescript',
|
||||||
|
dynamicImport: true,
|
||||||
|
topLevelAwait: false,
|
||||||
|
tsx: false,
|
||||||
|
decorators: true,
|
||||||
|
},
|
||||||
|
target: 'es2022',
|
||||||
|
externalHelpers: false,
|
||||||
|
transform: {
|
||||||
|
useDefineForClassFields: false,
|
||||||
|
decoratorVersion: '2022-03',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
sourceMaps: true,
|
||||||
|
inlineSourcesContent: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.tsx$/,
|
||||||
exclude: /node_modules/,
|
exclude: /node_modules/,
|
||||||
loader: 'swc-loader',
|
loader: 'swc-loader',
|
||||||
options: {
|
options: {
|
||||||
@@ -333,7 +359,11 @@ export const createConfiguration: (
|
|||||||
plugins: compact([
|
plugins: compact([
|
||||||
IN_CI ? null : new webpack.ProgressPlugin({ percentBy: 'entries' }),
|
IN_CI ? null : new webpack.ProgressPlugin({ percentBy: 'entries' }),
|
||||||
buildFlags.mode === 'development'
|
buildFlags.mode === 'development'
|
||||||
? new ReactRefreshWebpackPlugin({ overlay: false, esModule: true })
|
? new ReactRefreshWebpackPlugin({
|
||||||
|
overlay: false,
|
||||||
|
esModule: true,
|
||||||
|
include: /\.tsx$/,
|
||||||
|
})
|
||||||
: // todo: support multiple entry points
|
: // todo: support multiple entry points
|
||||||
new MiniCssExtractPlugin({
|
new MiniCssExtractPlugin({
|
||||||
filename: `[name].[contenthash:8].css`,
|
filename: `[name].[contenthash:8].css`,
|
||||||
|
|||||||
Reference in New Issue
Block a user