fix(nextjs): remove duplicated public folder in dist (#4389)
This commit is contained in:
parent
37e115589b
commit
09a205c995
@ -39,6 +39,8 @@
|
||||
"@angular-devkit/schematics": "~11.0.1",
|
||||
"@svgr/webpack": "^5.4.0",
|
||||
"chalk": "4.1.0",
|
||||
"copy-webpack-plugin": "6.0.3",
|
||||
"fs-extra": "7.0.1",
|
||||
"url-loader": "^3.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ import { getMockContext } from '../../utils/testing';
|
||||
import { NextBuildBuilderOptions } from '../../utils/types';
|
||||
import { run } from './build.impl';
|
||||
|
||||
jest.mock('fs-extra');
|
||||
jest.mock('next/dist/build');
|
||||
jest.mock('./lib/create-package-json', () => {
|
||||
return {
|
||||
|
||||
@ -6,13 +6,14 @@ import {
|
||||
import build from 'next/dist/build';
|
||||
import { PHASE_PRODUCTION_BUILD } from 'next/dist/next-server/lib/constants';
|
||||
import * as path from 'path';
|
||||
import { copyFileSync } from 'fs';
|
||||
import { copySync } from 'fs-extra';
|
||||
import { from, Observable } from 'rxjs';
|
||||
import { concatMap, map } from 'rxjs/operators';
|
||||
import { concatMap, map, tap } from 'rxjs/operators';
|
||||
import { prepareConfig } from '../../utils/config';
|
||||
import { NextBuildBuilderOptions } from '../../utils/types';
|
||||
import { createPackageJson } from './lib/create-package-json';
|
||||
import { createNextConfigFile } from './lib/create-next-config-file';
|
||||
import { join } from 'path';
|
||||
|
||||
try {
|
||||
require('dotenv').config();
|
||||
@ -29,6 +30,9 @@ export function run(
|
||||
return from(build(root, config as any)).pipe(
|
||||
concatMap(() => from(createPackageJson(options, context))),
|
||||
concatMap(() => from(createNextConfigFile(options, context))),
|
||||
tap(() => {
|
||||
copySync(join(root, 'public'), join(options.outputPath, 'public'));
|
||||
}),
|
||||
map(() => ({ success: true }))
|
||||
);
|
||||
}
|
||||
|
||||
@ -10,7 +10,7 @@ import { TsconfigPathsPlugin } from 'tsconfig-paths-webpack-plugin';
|
||||
import { Configuration } from 'webpack';
|
||||
import { FileReplacement, NextBuildBuilderOptions } from './types';
|
||||
import { BuilderContext } from '@angular-devkit/architect';
|
||||
import { createCopyPlugin } from '@nrwl/web/src/utils/config';
|
||||
import * as CopyWebpackPlugin from 'copy-webpack-plugin';
|
||||
import { offsetFromRoot } from '@nrwl/devkit';
|
||||
|
||||
export function createWebpackConfig(
|
||||
@ -82,18 +82,6 @@ export function createWebpackConfig(
|
||||
}
|
||||
);
|
||||
|
||||
config.plugins.push(
|
||||
createCopyPlugin([
|
||||
{
|
||||
input: 'public',
|
||||
// distDir is `dist/apps/[name]/.next` and we want public to be copied
|
||||
// to `dist/apps/[name]/public` thus the `..` here.
|
||||
output: '../public',
|
||||
glob: '**/*',
|
||||
},
|
||||
])
|
||||
);
|
||||
|
||||
return config;
|
||||
};
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user