@@ -150,6 +150,18 @@ export async function createConfig(
|
||||
console.warn(`WARNING: Failed to read react-dom version, ${error}`);
|
||||
}
|
||||
|
||||
const resolvePlugins: webpack.ResolvePluginInstance[] = [
|
||||
new LinkedPackageResolvePlugin(paths.rootNodeModules, externalPkgs),
|
||||
];
|
||||
|
||||
if (!isDev) {
|
||||
resolvePlugins.push(
|
||||
new ModuleScopePlugin(
|
||||
[paths.targetSrc, paths.targetDev],
|
||||
[paths.targetPackageJson],
|
||||
),
|
||||
);
|
||||
}
|
||||
return {
|
||||
mode: isDev ? 'development' : 'production',
|
||||
profile: false,
|
||||
@@ -181,14 +193,7 @@ export async function createConfig(
|
||||
http: false,
|
||||
util: require.resolve('util/'),
|
||||
},
|
||||
plugins: [
|
||||
new LinkedPackageResolvePlugin(paths.rootNodeModules, externalPkgs),
|
||||
!isDev &&
|
||||
new ModuleScopePlugin(
|
||||
[paths.targetSrc, paths.targetDev],
|
||||
[paths.targetPackageJson],
|
||||
),
|
||||
].filter(Boolean),
|
||||
plugins: resolvePlugins,
|
||||
alias: resolveAliases,
|
||||
},
|
||||
module: {
|
||||
@@ -237,6 +242,19 @@ export async function createBackendConfig(
|
||||
runScriptNodeArgs.push('--inspect-brk');
|
||||
}
|
||||
|
||||
const resolvePlugins: webpack.ResolvePluginInstance[] = [
|
||||
new LinkedPackageResolvePlugin(paths.rootNodeModules, externalPkgs),
|
||||
];
|
||||
|
||||
if (!isDev) {
|
||||
resolvePlugins.push(
|
||||
new ModuleScopePlugin(
|
||||
[paths.targetSrc, paths.targetDev],
|
||||
[paths.targetPackageJson],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
mode: isDev ? 'development' : 'production',
|
||||
profile: false,
|
||||
@@ -276,14 +294,7 @@ export async function createBackendConfig(
|
||||
extensions: ['.ts', '.tsx', '.mjs', '.js', '.jsx', '.json'],
|
||||
mainFields: ['main'],
|
||||
modules: [paths.rootNodeModules, ...moduleDirs],
|
||||
plugins: [
|
||||
new LinkedPackageResolvePlugin(paths.rootNodeModules, externalPkgs),
|
||||
!isDev &&
|
||||
new ModuleScopePlugin(
|
||||
[paths.targetSrc, paths.targetDev],
|
||||
[paths.targetPackageJson],
|
||||
),
|
||||
].filter(Boolean),
|
||||
plugins: resolvePlugins,
|
||||
},
|
||||
module: {
|
||||
rules: loaders,
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import webpack, { ModuleOptions, WebpackPluginInstance } from 'webpack';
|
||||
import { ModuleOptions, WebpackPluginInstance } from 'webpack';
|
||||
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
|
||||
import { svgrTemplate } from '../svgrTemplate';
|
||||
import ReactRefreshPlugin from '@pmmmwh/react-refresh-webpack-plugin';
|
||||
@@ -110,11 +110,10 @@ export const transforms = (options: TransformOptions): Transforms => {
|
||||
test: [/\.icon\.svg$/],
|
||||
use: [
|
||||
{
|
||||
loader: require.resolve('@sucrase/webpack-loader'),
|
||||
loader: require.resolve('esbuild-loader'),
|
||||
options: {
|
||||
transforms: ['jsx'],
|
||||
disableESTransforms: true,
|
||||
production: !isDev,
|
||||
loader: 'jsx',
|
||||
target: 'es2015',
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -180,8 +179,12 @@ export const transforms = (options: TransformOptions): Transforms => {
|
||||
const plugins = new Array<WebpackPluginInstance>();
|
||||
|
||||
if (isDev) {
|
||||
plugins.push(new ReactRefreshPlugin());
|
||||
// plugins.push(new webpack.HotModuleReplacementPlugin());
|
||||
plugins.push(
|
||||
new ReactRefreshPlugin({
|
||||
esModule: true,
|
||||
overlay: { sockProtocol: 'ws' },
|
||||
}),
|
||||
);
|
||||
} else {
|
||||
plugins.push(
|
||||
new MiniCssExtractPlugin({
|
||||
|
||||
Reference in New Issue
Block a user