-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(webpack): add convertConfigToWebpackPlugin
- Loading branch information
1 parent
b61546f
commit 402c1c6
Showing
21 changed files
with
1,136 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
docs/generated/packages/webpack/generators/convert-config-to-webpack-plugin.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"name": "convert-config-to-webpack-plugin", | ||
"factory": "./src/generators/convert-config-to-webpack-plugin/convert-config-to-webpack-plugin", | ||
"schema": { | ||
"$schema": "https://json-schema.org/schema", | ||
"$id": "NxWebpackConvertConfigToWebpackPlugin", | ||
"description": "Convert existing Webpack project(s) using `@nx/webpack:webpack` executor that uses `withNx` to use `NxAppWebpackPlugin`. Defaults to migrating all projects. Pass '--project' to migrate only one target.", | ||
"title": "Convert Webpack project using withNx to NxAppWebpackPlugin", | ||
"type": "object", | ||
"properties": { | ||
"project": { | ||
"type": "string", | ||
"description": "The project to convert from using the `@nx/webpack:webpack` executor and `withNx` plugin to use `NxAppWebpackPlugin`.", | ||
"x-priority": "important" | ||
}, | ||
"skipFormat": { | ||
"type": "boolean", | ||
"description": "Whether to format files at the end of the migration.", | ||
"default": false | ||
} | ||
}, | ||
"presets": [] | ||
}, | ||
"description": "Convert the project to use the `NxAppWebpackPlugin` and `NxReactWebpackPlugin`.", | ||
"implementation": "/packages/webpack/src/generators/convert-config-to-webpack-plugin/convert-config-to-webpack-plugin.ts", | ||
"aliases": [], | ||
"hidden": false, | ||
"path": "/packages/webpack/src/generators/convert-config-to-webpack-plugin/schema.json", | ||
"type": "generator" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
e2e/webpack/src/__snapshots__/webpack.legacy.test.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Webpack Plugin (legacy) should convert withNx webpack config to a standard config using NxWebpackPlugin 1`] = ` | ||
"const { NxAppWebpackPlugin } = require('@nx/webpack/app-plugin'); | ||
const { NxReactWebpackPlugin } = require('@nx/react/webpack-plugin'); | ||
const { nxUseLegacyPlugin } = require('@nx/webpack'); | ||
// This file was migrated using @nx/webpack:convert-config-to-webpack-plugin from your './webpack.config.old.js' | ||
// Please check that the options here are correct as they were moved from the old webpack.config.js to this file. | ||
const options = {}; | ||
module.exports = async () => ({ | ||
plugins: [ | ||
new NxAppWebpackPlugin(), | ||
new NxReactWebpackPlugin({ | ||
// Uncomment this line if you don't want to use SVGR | ||
// See: https://react-svgr.com/ | ||
// svgr: false | ||
}), | ||
await nxUseLegacyPlugin(require('./webpack.config.old'), options), | ||
], | ||
}); | ||
" | ||
`; | ||
|
||
exports[`Webpack Plugin (legacy) should convert withNx webpack config to a standard config using NxWebpackPlugin 2`] = ` | ||
"{ | ||
"name": "app3224373", | ||
"$schema": "../node_modules/nx/schemas/project-schema.json", | ||
"projectType": "application", | ||
"sourceRoot": "app3224373/src", | ||
"tags": [], | ||
"targets": { | ||
"build": { | ||
"executor": "@nx/webpack:webpack", | ||
"outputs": ["{options.outputPath}"], | ||
"defaultConfiguration": "production", | ||
"options": { | ||
"target": "web", | ||
"outputPath": "dist/app3224373", | ||
"compiler": "swc", | ||
"main": "app3224373/src/main.ts", | ||
"tsConfig": "app3224373/tsconfig.app.json", | ||
"webpackConfig": "app3224373/webpack.config.js", | ||
"assets": ["app3224373/src/favicon.ico", "app3224373/src/assets"], | ||
"index": "app3224373/src/index.html", | ||
"baseHref": "/", | ||
"styles": ["app3224373/src/styles.css"], | ||
"scripts": [], | ||
"standardWebpackConfigFunction": true | ||
}, | ||
"configurations": { | ||
"production": { | ||
"optimization": true, | ||
"outputHashing": "all", | ||
"sourceMap": false, | ||
"namedChunks": false, | ||
"extractLicenses": true, | ||
"vendorChunk": false, | ||
"fileReplacements": [ | ||
{ | ||
"replace": "app3224373/src/environments/environment.ts", | ||
"with": "app3224373/src/environments/environment.prod.ts" | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"serve": { | ||
"executor": "@nx/webpack:dev-server", | ||
"options": { | ||
"buildTarget": "app3224373:build" | ||
}, | ||
"configurations": { | ||
"production": { | ||
"buildTarget": "app3224373:build:production" | ||
} | ||
} | ||
}, | ||
"lint": { | ||
"executor": "@nx/eslint:lint" | ||
}, | ||
"test": { | ||
"executor": "@nx/jest:jest", | ||
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"], | ||
"options": { | ||
"jestConfig": "app3224373/jest.config.ts" | ||
} | ||
} | ||
} | ||
} | ||
" | ||
`; | ||
|
||
exports[`Webpack Plugin (legacy) should convert withNx webpack config to a standard config using NxWebpackPlugin 3`] = ` | ||
"const { composePlugins } = require('@nx/webpack'); | ||
// Nx plugins for webpack. | ||
module.exports = composePlugins((config) => { | ||
// Update the webpack config as needed here. | ||
// e.g. \`config.plugins.push(new MyPlugin())\` | ||
return config; | ||
}); | ||
" | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.