feat(web): rename @nrwl/web:build to @nrwl/web:webpack (#7952)
This commit is contained in:
parent
49df712d5f
commit
157c6e0fb0
@ -1,6 +1,6 @@
|
|||||||
# @nrwl/web:rollup
|
# @nrwl/web:rollup
|
||||||
|
|
||||||
Package a library
|
Package a library using rollup
|
||||||
|
|
||||||
Options can be configured in `angular.json` when defining the executor, or when invoking it. Read more about how to configure targets and executors here: https://nx.dev/core-concepts/configuration#targets.
|
Options can be configured in `angular.json` when defining the executor, or when invoking it. Read more about how to configure targets and executors here: https://nx.dev/core-concepts/configuration#targets.
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
# @nrwl/web:build
|
# @nrwl/web:webpack
|
||||||
|
|
||||||
Build a application
|
Build an application using webpack
|
||||||
|
|
||||||
Options can be configured in `angular.json` when defining the executor, or when invoking it. Read more about how to configure targets and executors here: https://nx.dev/core-concepts/configuration#targets.
|
Options can be configured in `angular.json` when defining the executor, or when invoking it. Read more about how to configure targets and executors here: https://nx.dev/core-concepts/configuration#targets.
|
||||||
|
|
||||||
@ -15,7 +15,7 @@ The `angular.json` configuration file contains information about the targets and
|
|||||||
"projectType": "application",
|
"projectType": "application",
|
||||||
"architect": {
|
"architect": {
|
||||||
"build": {
|
"build": {
|
||||||
"builder": "@nrwl/web:build",
|
"builder": "@nrwl/web:webpack",
|
||||||
"outputs": ["dist/apps/myapp"],
|
"outputs": ["dist/apps/myapp"],
|
||||||
"dependsOn": [
|
"dependsOn": [
|
||||||
{
|
{
|
||||||
@ -137,7 +137,7 @@ The `outputs` property lists the folders the builder creates files in. The prope
|
|||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"build": {
|
"build": {
|
||||||
"builder": "@nrwl/web:build",
|
"builder": "@nrwl/web:webpack",
|
||||||
"outputs": ["dist/apps/myapp"],
|
"outputs": ["dist/apps/myapp"],
|
||||||
"options": {
|
"options": {
|
||||||
"index": "apps/myapp/src/app.html",
|
"index": "apps/myapp/src/app.html",
|
||||||
@ -154,7 +154,7 @@ The `configurations` property provides extra sets of values that will be merged
|
|||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"build": {
|
"build": {
|
||||||
"builder": "@nrwl/web:build",
|
"builder": "@nrwl/web:webpack",
|
||||||
"outputs": ["dist/apps/myapp"],
|
"outputs": ["dist/apps/myapp"],
|
||||||
"options": {
|
"options": {
|
||||||
"index": "apps/myapp/src/app.html",
|
"index": "apps/myapp/src/app.html",
|
||||||
@ -186,7 +186,7 @@ Targets can depend on other targets. A common scenario is having to build depend
|
|||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"build": {
|
"build": {
|
||||||
"executor": "@nrwl/web:build",
|
"executor": "@nrwl/web:webpack",
|
||||||
"outputs": ["dist/apps/myapp"],
|
"outputs": ["dist/apps/myapp"],
|
||||||
"options": {
|
"options": {
|
||||||
"index": "apps/myapp/src/app.html",
|
"index": "apps/myapp/src/app.html",
|
||||||
@ -211,7 +211,7 @@ In the following example invoking `nx build myapp` builds all the libraries firs
|
|||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"build-base": {
|
"build-base": {
|
||||||
"executor": "@nrwl/web:build",
|
"executor": "@nrwl/web:webpack",
|
||||||
"outputs": ["dist/apps/myapp"],
|
"outputs": ["dist/apps/myapp"],
|
||||||
"options": {
|
"options": {
|
||||||
"index": "apps/myapp/src/app.html",
|
"index": "apps/myapp/src/app.html",
|
||||||
|
|||||||
@ -411,7 +411,7 @@ To use webpack instead of gulp, go back to your `angular.json` file and modify t
|
|||||||
```json
|
```json
|
||||||
...
|
...
|
||||||
"build": {
|
"build": {
|
||||||
"executor": "@nrwl/web:build",
|
"executor": "@nrwl/web:webpack",
|
||||||
"options": {
|
"options": {
|
||||||
"outputPath": "dist/apps/realworld",
|
"outputPath": "dist/apps/realworld",
|
||||||
"index": "apps/realworld/src/index.html",
|
"index": "apps/realworld/src/index.html",
|
||||||
|
|||||||
@ -394,7 +394,7 @@
|
|||||||
{
|
{
|
||||||
"name": "build executor",
|
"name": "build executor",
|
||||||
"id": "build",
|
"id": "build",
|
||||||
"file": "angular/api-web/executors/build"
|
"file": "angular/api-web/executors/webpack"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "dev-server executor",
|
"name": "dev-server executor",
|
||||||
@ -1718,7 +1718,7 @@
|
|||||||
{
|
{
|
||||||
"name": "build executor",
|
"name": "build executor",
|
||||||
"id": "build",
|
"id": "build",
|
||||||
"file": "react/api-web/executors/build"
|
"file": "react/api-web/executors/webpack"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "dev-server executor",
|
"name": "dev-server executor",
|
||||||
@ -3006,7 +3006,7 @@
|
|||||||
{
|
{
|
||||||
"name": "build executor",
|
"name": "build executor",
|
||||||
"id": "build",
|
"id": "build",
|
||||||
"file": "node/api-web/executors/build"
|
"file": "node/api-web/executors/webpack"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "dev-server executor",
|
"name": "dev-server executor",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
# @nrwl/web:rollup
|
# @nrwl/web:rollup
|
||||||
|
|
||||||
Package a library
|
Package a library using rollup
|
||||||
|
|
||||||
Options can be configured in `workspace.json` when defining the executor, or when invoking it. Read more about how to configure targets and executors here: https://nx.dev/core-concepts/configuration#targets.
|
Options can be configured in `workspace.json` when defining the executor, or when invoking it. Read more about how to configure targets and executors here: https://nx.dev/core-concepts/configuration#targets.
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
# @nrwl/web:build
|
# @nrwl/web:webpack
|
||||||
|
|
||||||
Build a application
|
Build an application using webpack
|
||||||
|
|
||||||
Options can be configured in `workspace.json` when defining the executor, or when invoking it. Read more about how to configure targets and executors here: https://nx.dev/core-concepts/configuration#targets.
|
Options can be configured in `workspace.json` when defining the executor, or when invoking it. Read more about how to configure targets and executors here: https://nx.dev/core-concepts/configuration#targets.
|
||||||
|
|
||||||
@ -1,6 +1,6 @@
|
|||||||
# @nrwl/web:rollup
|
# @nrwl/web:rollup
|
||||||
|
|
||||||
Package a library
|
Package a library using rollup
|
||||||
|
|
||||||
Options can be configured in `workspace.json` when defining the executor, or when invoking it. Read more about how to configure targets and executors here: https://nx.dev/core-concepts/configuration#targets.
|
Options can be configured in `workspace.json` when defining the executor, or when invoking it. Read more about how to configure targets and executors here: https://nx.dev/core-concepts/configuration#targets.
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
# @nrwl/web:build
|
# @nrwl/web:webpack
|
||||||
|
|
||||||
Build a application
|
Build an application using webpack
|
||||||
|
|
||||||
Options can be configured in `workspace.json` when defining the executor, or when invoking it. Read more about how to configure targets and executors here: https://nx.dev/core-concepts/configuration#targets.
|
Options can be configured in `workspace.json` when defining the executor, or when invoking it. Read more about how to configure targets and executors here: https://nx.dev/core-concepts/configuration#targets.
|
||||||
|
|
||||||
@ -257,7 +257,7 @@ This is an example of `apps/myapp/project.json`:
|
|||||||
"projectType": "application",
|
"projectType": "application",
|
||||||
"targets": {
|
"targets": {
|
||||||
"build": {
|
"build": {
|
||||||
"executor": "@nrwl/web:build",
|
"executor": "@nrwl/web:webpack",
|
||||||
"outputs": ["dist/apps/myapp"],
|
"outputs": ["dist/apps/myapp"],
|
||||||
"dependsOn": [
|
"dependsOn": [
|
||||||
{
|
{
|
||||||
@ -362,7 +362,7 @@ The `configurations` property provides extra sets of values that are merged into
|
|||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"build": {
|
"build": {
|
||||||
"executor": "@nrwl/web:build",
|
"executor": "@nrwl/web:webpack",
|
||||||
"outputs": ["dist/apps/myapp"],
|
"outputs": ["dist/apps/myapp"],
|
||||||
"options": {
|
"options": {
|
||||||
"index": "apps/myapp/src/app.html",
|
"index": "apps/myapp/src/app.html",
|
||||||
@ -397,7 +397,7 @@ building the project. You can specify this using the `dependsOn`.
|
|||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"build": {
|
"build": {
|
||||||
"executor": "@nrwl/web:build",
|
"executor": "@nrwl/web:webpack",
|
||||||
"outputs": ["dist/apps/myapp"],
|
"outputs": ["dist/apps/myapp"],
|
||||||
"options": {
|
"options": {
|
||||||
"index": "apps/myapp/src/app.html",
|
"index": "apps/myapp/src/app.html",
|
||||||
@ -425,7 +425,7 @@ executed and only then `nx build myapp` is executed.
|
|||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"build-base": {
|
"build-base": {
|
||||||
"executor": "@nrwl/web:build",
|
"executor": "@nrwl/web:webpack",
|
||||||
"outputs": ["dist/apps/myapp"],
|
"outputs": ["dist/apps/myapp"],
|
||||||
"options": {
|
"options": {
|
||||||
"index": "apps/myapp/src/app.html",
|
"index": "apps/myapp/src/app.html",
|
||||||
|
|||||||
@ -130,7 +130,7 @@ Nx also caches the files generated by a command. The list of folders is listed i
|
|||||||
"projectType": "application",
|
"projectType": "application",
|
||||||
"architect": {
|
"architect": {
|
||||||
"build": {
|
"build": {
|
||||||
"builder": "@nrwl/web:build",
|
"builder": "@nrwl/web:webpack",
|
||||||
"outputs": ["dist/apps/myapp"],
|
"outputs": ["dist/apps/myapp"],
|
||||||
"options": {
|
"options": {
|
||||||
"index": "apps/myapp/src/app.html",
|
"index": "apps/myapp/src/app.html",
|
||||||
|
|||||||
@ -21,7 +21,7 @@ The executors that are available for each project are defined and configured in
|
|||||||
"generators": {},
|
"generators": {},
|
||||||
"targets": {
|
"targets": {
|
||||||
"build": {
|
"build": {
|
||||||
"executor": "@nrwl/web:build",
|
"executor": "@nrwl/web:webpack",
|
||||||
"options": {
|
"options": {
|
||||||
"outputPath": "dist/apps/cart",
|
"outputPath": "dist/apps/cart",
|
||||||
...
|
...
|
||||||
|
|||||||
@ -91,7 +91,7 @@ describe('update 10.0.0', () => {
|
|||||||
sourceRoot: 'apps/cart/src',
|
sourceRoot: 'apps/cart/src',
|
||||||
architect: {
|
architect: {
|
||||||
build: {
|
build: {
|
||||||
builder: '@nrwl/web:build',
|
builder: '@nrwl/web:webpack',
|
||||||
},
|
},
|
||||||
test: {
|
test: {
|
||||||
builder: '@nrwl/jest:jest',
|
builder: '@nrwl/jest:jest',
|
||||||
|
|||||||
@ -135,7 +135,7 @@ describe('Add next eslint 12.6.0', () => {
|
|||||||
root: 'apps/app1',
|
root: 'apps/app1',
|
||||||
targets: {
|
targets: {
|
||||||
build: {
|
build: {
|
||||||
executor: '@nrwl/web:build',
|
executor: '@nrwl/web:webpack',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@ -271,7 +271,7 @@ Object {
|
|||||||
|
|
||||||
const workspaceJson = getProjects(appTree);
|
const workspaceJson = getProjects(appTree);
|
||||||
const targetConfig = workspaceJson.get('my-app').targets;
|
const targetConfig = workspaceJson.get('my-app').targets;
|
||||||
expect(targetConfig.build.executor).toEqual('@nrwl/web:build');
|
expect(targetConfig.build.executor).toEqual('@nrwl/web:webpack');
|
||||||
expect(targetConfig.build.outputs).toEqual(['{options.outputPath}']);
|
expect(targetConfig.build.outputs).toEqual(['{options.outputPath}']);
|
||||||
expect(targetConfig.build.options).toEqual({
|
expect(targetConfig.build.options).toEqual({
|
||||||
assets: ['apps/my-app/src/favicon.ico', 'apps/my-app/src/assets'],
|
assets: ['apps/my-app/src/favicon.ico', 'apps/my-app/src/assets'],
|
||||||
|
|||||||
@ -36,7 +36,7 @@ function maybeJs(options: NormalizedSchema, path: string): string {
|
|||||||
|
|
||||||
function createBuildTarget(options: NormalizedSchema): TargetConfiguration {
|
function createBuildTarget(options: NormalizedSchema): TargetConfiguration {
|
||||||
return {
|
return {
|
||||||
executor: '@nrwl/web:build',
|
executor: '@nrwl/web:webpack',
|
||||||
outputs: ['{options.outputPath}'],
|
outputs: ['{options.outputPath}'],
|
||||||
defaultConfiguration: 'production',
|
defaultConfiguration: 'production',
|
||||||
options: {
|
options: {
|
||||||
|
|||||||
@ -89,7 +89,8 @@ function isReactProject(p) {
|
|||||||
p.architect && p.architect.build ? p.architect.build : null;
|
p.architect && p.architect.build ? p.architect.build : null;
|
||||||
return (
|
return (
|
||||||
buildArchitect &&
|
buildArchitect &&
|
||||||
buildArchitect.builder === '@nrwl/web:build' &&
|
(buildArchitect.builder === '@nrwl/web:webpack' ||
|
||||||
|
buildArchitect.builder === '@nrwl/web:build') &&
|
||||||
(buildArchitect.options.webpackConfig === '@nrwl/react/plugins/babel' ||
|
(buildArchitect.options.webpackConfig === '@nrwl/react/plugins/babel' ||
|
||||||
buildArchitect.options.webpackConfig === '@nrwl/react/plugins/webpack')
|
buildArchitect.options.webpackConfig === '@nrwl/react/plugins/webpack')
|
||||||
);
|
);
|
||||||
|
|||||||
@ -37,7 +37,8 @@ function isReactProject(p) {
|
|||||||
p.architect && p.architect.build ? p.architect.build : null;
|
p.architect && p.architect.build ? p.architect.build : null;
|
||||||
return (
|
return (
|
||||||
buildArchitect &&
|
buildArchitect &&
|
||||||
buildArchitect.builder === '@nrwl/web:build' &&
|
(buildArchitect.builder === '@nrwl/web:build' ||
|
||||||
|
buildArchitect.builder === '@nrwl/web:webpack') &&
|
||||||
(buildArchitect.options.webpackConfig === '@nrwl/react/plugins/babel' ||
|
(buildArchitect.options.webpackConfig === '@nrwl/react/plugins/babel' ||
|
||||||
buildArchitect.options.webpackConfig === '@nrwl/react/plugins/webpack')
|
buildArchitect.options.webpackConfig === '@nrwl/react/plugins/webpack')
|
||||||
);
|
);
|
||||||
|
|||||||
@ -1,14 +1,14 @@
|
|||||||
{
|
{
|
||||||
"builders": {
|
"builders": {
|
||||||
"build": {
|
"webpack": {
|
||||||
"implementation": "./src/executors/build/compat",
|
"implementation": "./src/executors/webpack/compat",
|
||||||
"schema": "./src/executors/build/schema.json",
|
"schema": "./src/executors/webpack/schema.json",
|
||||||
"description": "Build a application"
|
"description": "Build an application using webpack"
|
||||||
},
|
},
|
||||||
"rollup": {
|
"rollup": {
|
||||||
"implementation": "./src/executors/rollup/rollup.impl",
|
"implementation": "./src/executors/rollup/rollup.impl",
|
||||||
"schema": "./src/executors/rollup/schema.json",
|
"schema": "./src/executors/rollup/schema.json",
|
||||||
"description": "Package a library"
|
"description": "Package a library using rollup"
|
||||||
},
|
},
|
||||||
"dev-server": {
|
"dev-server": {
|
||||||
"implementation": "./src/executors/dev-server/compat",
|
"implementation": "./src/executors/dev-server/compat",
|
||||||
@ -22,15 +22,15 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"executors": {
|
"executors": {
|
||||||
"build": {
|
"webpack": {
|
||||||
"implementation": "./src/executors/build/build.impl",
|
"implementation": "./src/executors/webpack/webpack.impl",
|
||||||
"schema": "./src/executors/build/schema.json",
|
"schema": "./src/executors/webpack/schema.json",
|
||||||
"description": "Build a application"
|
"description": "Build an application using webpack"
|
||||||
},
|
},
|
||||||
"rollup": {
|
"rollup": {
|
||||||
"implementation": "./src/executors/rollup/rollup.impl",
|
"implementation": "./src/executors/rollup/rollup.impl",
|
||||||
"schema": "./src/executors/rollup/schema.json",
|
"schema": "./src/executors/rollup/schema.json",
|
||||||
"description": "Package a library"
|
"description": "Package a library using rollup"
|
||||||
},
|
},
|
||||||
"dev-server": {
|
"dev-server": {
|
||||||
"implementation": "./src/executors/dev-server/dev-server.impl",
|
"implementation": "./src/executors/dev-server/dev-server.impl",
|
||||||
|
|||||||
@ -11,7 +11,7 @@ import { map, tap } from 'rxjs/operators';
|
|||||||
import * as WebpackDevServer from 'webpack-dev-server';
|
import * as WebpackDevServer from 'webpack-dev-server';
|
||||||
|
|
||||||
import { normalizeWebBuildOptions } from '../../utils/normalize';
|
import { normalizeWebBuildOptions } from '../../utils/normalize';
|
||||||
import { WebBuildExecutorOptions } from '../build/build.impl';
|
import { WebWebpackExecutorOptions } from '../webpack/webpack.impl';
|
||||||
import { getDevServerConfig } from '../../utils/devserver.config';
|
import { getDevServerConfig } from '../../utils/devserver.config';
|
||||||
import {
|
import {
|
||||||
calculateProjectDependencies,
|
calculateProjectDependencies,
|
||||||
@ -106,9 +106,9 @@ export default async function* devServerExecutor(
|
|||||||
function getBuildOptions(
|
function getBuildOptions(
|
||||||
options: WebDevServerOptions,
|
options: WebDevServerOptions,
|
||||||
context: ExecutorContext
|
context: ExecutorContext
|
||||||
): WebBuildExecutorOptions {
|
): WebWebpackExecutorOptions {
|
||||||
const target = parseTargetString(options.buildTarget);
|
const target = parseTargetString(options.buildTarget);
|
||||||
const overrides: Partial<WebBuildExecutorOptions> = {
|
const overrides: Partial<WebWebpackExecutorOptions> = {
|
||||||
watch: false,
|
watch: false,
|
||||||
};
|
};
|
||||||
if (options.maxWorkers) {
|
if (options.maxWorkers) {
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { convertNxExecutor } from '@nrwl/devkit';
|
import { convertNxExecutor } from '@nrwl/devkit';
|
||||||
|
|
||||||
import { run } from './build.impl';
|
import { run } from './webpack.impl';
|
||||||
|
|
||||||
export default convertNxExecutor(run);
|
export default convertNxExecutor(run);
|
||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"title": "Web Application Build Target",
|
"title": "Webpack Executor",
|
||||||
"description": "Web application build target options for Build Facade",
|
"description": "Builds web applications using webpack",
|
||||||
"cli": "nx",
|
"cli": "nx",
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
@ -27,7 +27,7 @@ import {
|
|||||||
writeIndexHtml,
|
writeIndexHtml,
|
||||||
} from '../../utils/webpack/write-index-html';
|
} from '../../utils/webpack/write-index-html';
|
||||||
|
|
||||||
export interface WebBuildExecutorOptions extends BuildBuilderOptions {
|
export interface WebWebpackExecutorOptions extends BuildBuilderOptions {
|
||||||
index: string;
|
index: string;
|
||||||
budgets?: any[];
|
budgets?: any[];
|
||||||
baseHref?: string;
|
baseHref?: string;
|
||||||
@ -58,7 +58,7 @@ export interface WebBuildExecutorOptions extends BuildBuilderOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getWebpackConfigs(
|
function getWebpackConfigs(
|
||||||
options: WebBuildExecutorOptions,
|
options: WebWebpackExecutorOptions,
|
||||||
context: ExecutorContext
|
context: ExecutorContext
|
||||||
): Configuration[] {
|
): Configuration[] {
|
||||||
const metadata = context.workspace.projects[context.projectName];
|
const metadata = context.workspace.projects[context.projectName];
|
||||||
@ -115,7 +115,7 @@ function getWebpackConfigs(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function* run(
|
export async function* run(
|
||||||
options: WebBuildExecutorOptions,
|
options: WebWebpackExecutorOptions,
|
||||||
context: ExecutorContext
|
context: ExecutorContext
|
||||||
) {
|
) {
|
||||||
// Node versions 12.2-12.8 has a bug where prod builds will hang for 2-3 minutes
|
// Node versions 12.2-12.8 has a bug where prod builds will hang for 2-3 minutes
|
||||||
@ -254,7 +254,7 @@ describe('app', () => {
|
|||||||
});
|
});
|
||||||
const workspaceJson = readJson(tree, 'workspace.json');
|
const workspaceJson = readJson(tree, 'workspace.json');
|
||||||
const architectConfig = workspaceJson.projects['my-app'].architect;
|
const architectConfig = workspaceJson.projects['my-app'].architect;
|
||||||
expect(architectConfig.build.builder).toEqual('@nrwl/web:build');
|
expect(architectConfig.build.builder).toEqual('@nrwl/web:webpack');
|
||||||
expect(architectConfig.build.outputs).toEqual(['{options.outputPath}']);
|
expect(architectConfig.build.outputs).toEqual(['{options.outputPath}']);
|
||||||
expect(architectConfig.build.options).toEqual({
|
expect(architectConfig.build.options).toEqual({
|
||||||
assets: ['apps/my-app/src/favicon.ico', 'apps/my-app/src/assets'],
|
assets: ['apps/my-app/src/favicon.ico', 'apps/my-app/src/assets'],
|
||||||
|
|||||||
@ -23,7 +23,7 @@ import { cypressProjectGenerator } from '@nrwl/cypress';
|
|||||||
import { Linter, lintProjectGenerator } from '@nrwl/linter';
|
import { Linter, lintProjectGenerator } from '@nrwl/linter';
|
||||||
import { jestProjectGenerator } from '@nrwl/jest';
|
import { jestProjectGenerator } from '@nrwl/jest';
|
||||||
|
|
||||||
import { WebBuildExecutorOptions } from '../../executors/build/build.impl';
|
import { WebWebpackExecutorOptions } from '../../executors/webpack/webpack.impl';
|
||||||
import { Schema } from './schema';
|
import { Schema } from './schema';
|
||||||
|
|
||||||
interface NormalizedSchema extends Schema {
|
interface NormalizedSchema extends Schema {
|
||||||
@ -50,7 +50,7 @@ function addBuildTarget(
|
|||||||
project: ProjectConfiguration,
|
project: ProjectConfiguration,
|
||||||
options: NormalizedSchema
|
options: NormalizedSchema
|
||||||
): ProjectConfiguration {
|
): ProjectConfiguration {
|
||||||
const buildOptions: WebBuildExecutorOptions = {
|
const buildOptions: WebWebpackExecutorOptions = {
|
||||||
outputPath: joinPathFragments('dist', options.appProjectRoot),
|
outputPath: joinPathFragments('dist', options.appProjectRoot),
|
||||||
index: joinPathFragments(options.appProjectRoot, 'src/index.html'),
|
index: joinPathFragments(options.appProjectRoot, 'src/index.html'),
|
||||||
baseHref: '/',
|
baseHref: '/',
|
||||||
@ -66,7 +66,7 @@ function addBuildTarget(
|
|||||||
],
|
],
|
||||||
scripts: [],
|
scripts: [],
|
||||||
};
|
};
|
||||||
const productionBuildOptions: Partial<WebBuildExecutorOptions> = {
|
const productionBuildOptions: Partial<WebWebpackExecutorOptions> = {
|
||||||
fileReplacements: [
|
fileReplacements: [
|
||||||
{
|
{
|
||||||
replace: joinPathFragments(
|
replace: joinPathFragments(
|
||||||
@ -92,7 +92,7 @@ function addBuildTarget(
|
|||||||
targets: {
|
targets: {
|
||||||
...project.targets,
|
...project.targets,
|
||||||
build: {
|
build: {
|
||||||
executor: '@nrwl/web:build',
|
executor: '@nrwl/web:webpack',
|
||||||
outputs: ['{options.outputPath}'],
|
outputs: ['{options.outputPath}'],
|
||||||
defaultConfiguration: 'production',
|
defaultConfiguration: 'production',
|
||||||
options: buildOptions,
|
options: buildOptions,
|
||||||
|
|||||||
@ -0,0 +1,49 @@
|
|||||||
|
import { readJson } from '@nrwl/devkit';
|
||||||
|
import { createTreeWithEmptyWorkspace } from '@nrwl/devkit/testing';
|
||||||
|
|
||||||
|
import rename from './rename-build-to-webpack';
|
||||||
|
|
||||||
|
describe('Migration: rename build to webpack', () => {
|
||||||
|
it(`should rename the "build" executor to "webpack"`, async () => {
|
||||||
|
let tree = createTreeWithEmptyWorkspace();
|
||||||
|
|
||||||
|
tree.write(
|
||||||
|
'workspace.json',
|
||||||
|
JSON.stringify({
|
||||||
|
version: 2,
|
||||||
|
projects: {
|
||||||
|
myapp: {
|
||||||
|
root: 'apps/myapp',
|
||||||
|
sourceRoot: 'apps/myapp/src',
|
||||||
|
projectType: 'application',
|
||||||
|
targets: {
|
||||||
|
build: {
|
||||||
|
executor: '@nrwl/web:build',
|
||||||
|
options: {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
await rename(tree);
|
||||||
|
|
||||||
|
expect(readJson(tree, 'workspace.json')).toEqual({
|
||||||
|
version: 2,
|
||||||
|
projects: {
|
||||||
|
myapp: {
|
||||||
|
root: 'apps/myapp',
|
||||||
|
sourceRoot: 'apps/myapp/src',
|
||||||
|
projectType: 'application',
|
||||||
|
targets: {
|
||||||
|
build: {
|
||||||
|
executor: '@nrwl/web:webpack',
|
||||||
|
options: {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -0,0 +1,20 @@
|
|||||||
|
import {
|
||||||
|
formatFiles,
|
||||||
|
getProjects,
|
||||||
|
Tree,
|
||||||
|
updateProjectConfiguration,
|
||||||
|
} from '@nrwl/devkit';
|
||||||
|
|
||||||
|
export default async function update(host: Tree) {
|
||||||
|
const projects = getProjects(host);
|
||||||
|
|
||||||
|
for (const [name, config] of projects.entries()) {
|
||||||
|
if (config?.targets?.build?.executor !== '@nrwl/web:build') return;
|
||||||
|
|
||||||
|
config.targets.build.executor = '@nrwl/web:webpack';
|
||||||
|
|
||||||
|
updateProjectConfiguration(host, name, config);
|
||||||
|
}
|
||||||
|
|
||||||
|
await formatFiles(host);
|
||||||
|
}
|
||||||
@ -4,7 +4,7 @@ import * as path from 'path';
|
|||||||
import { basename, resolve } from 'path';
|
import { basename, resolve } from 'path';
|
||||||
|
|
||||||
import { getWebConfig } from './web.config';
|
import { getWebConfig } from './web.config';
|
||||||
import { WebBuildExecutorOptions } from '../executors/build/build.impl';
|
import { WebWebpackExecutorOptions } from '../executors/webpack/webpack.impl';
|
||||||
import { WebDevServerOptions } from '../executors/dev-server/dev-server.impl';
|
import { WebDevServerOptions } from '../executors/dev-server/dev-server.impl';
|
||||||
import { buildServePath } from './serve-path';
|
import { buildServePath } from './serve-path';
|
||||||
import { OptimizationOptions } from './shared-models';
|
import { OptimizationOptions } from './shared-models';
|
||||||
@ -16,7 +16,7 @@ export function getDevServerConfig(
|
|||||||
workspaceRoot: string,
|
workspaceRoot: string,
|
||||||
projectRoot: string,
|
projectRoot: string,
|
||||||
sourceRoot: string,
|
sourceRoot: string,
|
||||||
buildOptions: WebBuildExecutorOptions,
|
buildOptions: WebWebpackExecutorOptions,
|
||||||
serveOptions: WebDevServerOptions
|
serveOptions: WebDevServerOptions
|
||||||
): Partial<WebpackDevServerConfiguration> {
|
): Partial<WebpackDevServerConfiguration> {
|
||||||
const webpackConfig = getWebConfig(
|
const webpackConfig = getWebConfig(
|
||||||
@ -62,7 +62,7 @@ export function getDevServerConfig(
|
|||||||
function getDevServerPartial(
|
function getDevServerPartial(
|
||||||
root: string,
|
root: string,
|
||||||
options: WebDevServerOptions,
|
options: WebDevServerOptions,
|
||||||
buildOptions: WebBuildExecutorOptions
|
buildOptions: WebWebpackExecutorOptions
|
||||||
): WebpackDevServerConfiguration {
|
): WebpackDevServerConfiguration {
|
||||||
const servePath = buildServePath(buildOptions);
|
const servePath = buildServePath(buildOptions);
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { WebBuildExecutorOptions } from '../executors/build/build.impl';
|
import { WebWebpackExecutorOptions } from '../executors/webpack/webpack.impl';
|
||||||
import { normalizePath } from '@nrwl/devkit';
|
import { normalizePath } from '@nrwl/devkit';
|
||||||
import { basename, dirname, relative, resolve } from 'path';
|
import { basename, dirname, relative, resolve } from 'path';
|
||||||
import {
|
import {
|
||||||
@ -101,10 +101,10 @@ function normalizeFileReplacements(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function normalizeWebBuildOptions(
|
export function normalizeWebBuildOptions(
|
||||||
options: WebBuildExecutorOptions,
|
options: WebWebpackExecutorOptions,
|
||||||
root: string,
|
root: string,
|
||||||
sourceRoot: string
|
sourceRoot: string
|
||||||
): WebBuildExecutorOptions {
|
): WebWebpackExecutorOptions {
|
||||||
return {
|
return {
|
||||||
...normalizeBuildOptions(options, root, sourceRoot),
|
...normalizeBuildOptions(options, root, sourceRoot),
|
||||||
optimization:
|
optimization:
|
||||||
@ -122,7 +122,7 @@ export function normalizeWebBuildOptions(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function convertBuildOptions(
|
export function convertBuildOptions(
|
||||||
buildOptions: WebBuildExecutorOptions
|
buildOptions: WebWebpackExecutorOptions
|
||||||
): any {
|
): any {
|
||||||
const options = buildOptions as any;
|
const options = buildOptions as any;
|
||||||
return <any>{
|
return <any>{
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { WebBuildExecutorOptions } from '../executors/build/build.impl';
|
import { WebWebpackExecutorOptions } from '../executors/webpack/webpack.impl';
|
||||||
|
|
||||||
export function buildServePath(browserOptions: WebBuildExecutorOptions) {
|
export function buildServePath(browserOptions: WebWebpackExecutorOptions) {
|
||||||
let servePath =
|
let servePath =
|
||||||
_findDefaultServePath(browserOptions.baseHref, browserOptions.deployUrl) ||
|
_findDefaultServePath(browserOptions.baseHref, browserOptions.deployUrl) ||
|
||||||
'/';
|
'/';
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { WebBuildExecutorOptions } from '../executors/build/build.impl';
|
import { WebWebpackExecutorOptions } from '../executors/webpack/webpack.impl';
|
||||||
import { FileReplacement } from './normalize';
|
import { FileReplacement } from './normalize';
|
||||||
|
|
||||||
export interface OptimizationOptions {
|
export interface OptimizationOptions {
|
||||||
@ -109,7 +109,7 @@ export interface StylePreprocessorOptions {
|
|||||||
includePaths?: string[];
|
includePaths?: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface WebpackConfigOptions<T = WebBuildExecutorOptions> {
|
export interface WebpackConfigOptions<T = WebWebpackExecutorOptions> {
|
||||||
root: string;
|
root: string;
|
||||||
projectRoot: string;
|
projectRoot: string;
|
||||||
sourceRoot?: string;
|
sourceRoot?: string;
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import { ScriptTarget } from 'typescript';
|
|||||||
import { getHashDigest, interpolateName } from 'loader-utils';
|
import { getHashDigest, interpolateName } from 'loader-utils';
|
||||||
import { Configuration } from 'webpack';
|
import { Configuration } from 'webpack';
|
||||||
|
|
||||||
import { WebBuildExecutorOptions } from '../executors/build/build.impl';
|
import { WebWebpackExecutorOptions } from '../executors/webpack/webpack.impl';
|
||||||
import { convertBuildOptions } from './normalize';
|
import { convertBuildOptions } from './normalize';
|
||||||
import { getBaseWebpackPartial } from './config';
|
import { getBaseWebpackPartial } from './config';
|
||||||
import { getBrowserConfig } from './webpack/partials/browser';
|
import { getBrowserConfig } from './webpack/partials/browser';
|
||||||
@ -27,7 +27,7 @@ export function getWebConfig(
|
|||||||
workspaceRoot,
|
workspaceRoot,
|
||||||
projectRoot,
|
projectRoot,
|
||||||
sourceRoot,
|
sourceRoot,
|
||||||
options: WebBuildExecutorOptions,
|
options: WebWebpackExecutorOptions,
|
||||||
esm?: boolean,
|
esm?: boolean,
|
||||||
isScriptOptimizeOn?: boolean,
|
isScriptOptimizeOn?: boolean,
|
||||||
configuration?: string
|
configuration?: string
|
||||||
@ -71,12 +71,12 @@ export function getWebConfig(
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getBrowserPartial(wco: any, options: WebBuildExecutorOptions) {
|
function getBrowserPartial(wco: any, options: WebWebpackExecutorOptions) {
|
||||||
return getBrowserConfig(wco);
|
return getBrowserConfig(wco);
|
||||||
}
|
}
|
||||||
|
|
||||||
function _getBaseWebpackPartial(
|
function _getBaseWebpackPartial(
|
||||||
options: WebBuildExecutorOptions,
|
options: WebWebpackExecutorOptions,
|
||||||
esm: boolean,
|
esm: boolean,
|
||||||
isScriptOptimizeOn: boolean,
|
isScriptOptimizeOn: boolean,
|
||||||
emitDecoratorMetadata: boolean,
|
emitDecoratorMetadata: boolean,
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import { RuleSetRule } from 'webpack';
|
import { RuleSetRule } from 'webpack';
|
||||||
|
|
||||||
import { WebBuildExecutorOptions } from '../../../executors/build/build.impl';
|
import { WebWebpackExecutorOptions } from '../../../executors/webpack/webpack.impl';
|
||||||
import { RemoveEmptyScriptsPlugin } from '../plugins/remove-empty-scripts-plugin';
|
import { RemoveEmptyScriptsPlugin } from '../plugins/remove-empty-scripts-plugin';
|
||||||
import { getOutputHashFormat } from '../../hash-format';
|
import { getOutputHashFormat } from '../../hash-format';
|
||||||
import { normalizeExtraEntryPoints } from '../../normalize';
|
import { normalizeExtraEntryPoints } from '../../normalize';
|
||||||
@ -18,7 +18,7 @@ const RawCssLoader = require.resolve(
|
|||||||
|
|
||||||
export function getStylesConfig(
|
export function getStylesConfig(
|
||||||
root: string,
|
root: string,
|
||||||
buildOptions: WebBuildExecutorOptions,
|
buildOptions: WebWebpackExecutorOptions,
|
||||||
includePaths: string[]
|
includePaths: string[]
|
||||||
) {
|
) {
|
||||||
const entryPoints: { [key: string]: string[] } = {};
|
const entryPoints: { [key: string]: string[] } = {};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user