fix(cli): remove modules from webpack config

This commit is contained in:
Ivan Shmidt
2020-06-10 23:29:26 +02:00
parent 96c295b0e1
commit 0331d33a37
5 changed files with 38 additions and 34 deletions
+1 -2
View File
@@ -34,10 +34,9 @@ export async function serveBackend(options: ServeOptions) {
poll: true,
},
(err: Error) => {
console.log('Build succeeded');
if (err) {
console.error(err);
}
} else console.log('Build succeeded');
},
);
+1
View File
@@ -40,6 +40,7 @@ export async function buildBundle(options: BuildOptions) {
...options,
checksEnabled: false,
isDev: false,
isBackend: false,
});
const compiler = webpack(config);
+30 -30
View File
@@ -79,39 +79,40 @@ export function createConfig(
}),
);
const backendRelatedConfig = {
watch: true,
watchOptions: {
ignored: [/node_modules\/(?!\@backstage)/],
},
externals: [
nodeExternals({
modulesDir: paths.rootNodeModules,
whitelist: [
'webpack/hot/poll?100',
/\@backstage\/.*\/(?!node_modules)/,
],
}),
nodeExternals({
modulesDir: paths.targetNodeModules,
whitelist: [
'webpack/hot/poll?100',
/\@backstage\/.*\/(?!node_modules)/,
],
}),
],
target: 'node' as const,
node: {
__dirname: true,
__filename: true,
global: true,
},
};
return {
mode: isDev ? 'development' : 'production',
profile: false,
...(isBackend
? {
watch: true,
watchOptions: {
ignored: [/node_modules\/(?!\@backstage)/],
// poll: 1000
},
externals: [
nodeExternals({
modulesDir: paths.rootNodeModules,
whitelist: [
'webpack/hot/poll?100',
/\@backstage\/.*\/(?!node_modules)/,
],
}),
nodeExternals({
modulesDir: paths.targetNodeModules,
whitelist: [
'webpack/hot/poll?100',
/\@backstage\/.*\/(?!node_modules)/,
],
}),
],
target: 'node',
node: {
__dirname: true,
__filename: true,
global: true,
},
}
? backendRelatedConfig
: {
node: {
module: 'empty',
@@ -140,7 +141,6 @@ export function createConfig(
resolve: {
extensions: ['.ts', '.tsx', '.mjs', '.js', '.jsx'],
mainFields: ['main:src', 'browser', 'module', 'main'],
modules: [paths.targetNodeModules, paths.rootNodeModules],
plugins: [
new ModuleScopePlugin(
[paths.targetSrc, paths.targetDev],
+5 -1
View File
@@ -38,7 +38,11 @@ export async function serveBundle(options: ServeOptions) {
const paths = resolveBundlingPaths(options);
const pkgPath = paths.targetPackageJson;
const pkg = await fs.readJson(pkgPath);
const config = createConfig(paths, { ...options, isDev: true });
const config = createConfig(paths, {
...options,
isDev: true,
isBackend: false,
});
const compiler = webpack(config);
const server = new WebpackDevServer(compiler, {
+1 -1
View File
@@ -22,7 +22,7 @@ export type BundlingOptions = {
isDev: boolean;
config: Config;
appConfigs: AppConfig[];
isBackend?: boolean;
isBackend: boolean;
};
export type ServeOptions = BundlingPathsOptions & {