15.0.0-rc.0 • Published 1 year ago

@nx-plus/vue v15.0.0-rc.0

Weekly downloads
6
License
MIT
Repository
github
Last release
1 year ago

Nx Plus Vue

First class support for Vue in your Nx workspace.

Contents

Prerequisite

Nx Workspace

If you have not already, create an Nx workspace with the following:

npx create-nx-workspace@^15.0.0

Peer Dependencies

If you have not already, install peer dependencies with the following:

# npm
npm install @nrwl/cypress@^15.0.0 @nrwl/jest@^15.0.0 @nrwl/linter@^15.0.0 --save-dev

# yarn
yarn add @nrwl/cypress@^15.0.0 @nrwl/jest@^15.0.0 @nrwl/linter@^15.0.0 --dev

Getting Started

Install Plugin

# npm
npm install @nx-plus/vue --save-dev

# yarn
yarn add @nx-plus/vue --dev

Generate Your App

nx g @nx-plus/vue:app my-app

Serve Your App

nx serve my-app

Nx Dependency Graph Support

Nx's dep-graph does not support .vue files. To patch support for .vue files, add the following npm script to your package.json:

"postinstall": "node node_modules/@nx-plus/vue/patch-nx-dep-graph.js"

Help us! We dislike this hack just as much as you do. Please give this Nx issue a 👍 so that we can remove this hack in the future.

Schematics (i.e. code generation)

Application

nx g @nx-plus/vue:app <name> [options]

ArgumentsDescription
<name>The name of your app.
OptionsDefaultDescription
--tags-Tags to use for linting (comma-delimited).
--directoryappsA directory where the project is placed.
--stylecssThe file extension to be used for style files.
--unitTestRunnerjestTest runner to use for unit tests.
--e2eTestRunnercypressTest runner to use for end to end (e2e) tests.
--routingfalseGenerate routing configuration.
--vueVersion2The version of Vue.js that you want to start the project with.
--skipFormatfalseSkip formatting files.
--babelfalseAdd Babel support.

Vuex

nx g @nx-plus/vue:vuex <project> [options]

ArgumentsDescription
<project>The name of the project you would like to add Vuex to.
OptionsDefaultDescription
--skipFormatfalseSkip formatting files.

Library

nx g @nx-plus/vue:lib <name> [options]

ArgumentsDescription
<name>The name of your library.
OptionsDefaultDescription
--tags-Tags to use for linting (comma-delimited).
--directorylibsA directory where the project is placed.
--unitTestRunnerjestTest runner to use for unit tests.
--skipFormatfalseSkip formatting files.
--skipTsConfigfalseDo not update tsconfig.json for development experience.
--vueVersion2The version of Vue.js that you want to start the project with.
--publishablefalseCreate a buildable library.
--babelfalseAdd Babel support.

Component

nx g @nx-plus/vue:component <name> [options]

ArgumentsDescription
<name>The name of your component.
OptionsDefaultDescription
--project-Tags to use for linting (comma-delimited).
--directory-A directory where the component is placed.
--stylecssThe file extension to be used for style files.

Builders (i.e. task runners)

Dev Server

nx serve <name> [options]

ArgumentsDescription
<name>The name of your app.
OptionsDefaultDescription
--openfalseOpen browser on server start.
--copyfalseCopy url to clipboard on server start.
--stdinfalseClose when stdin ends.
--modedevelopmentSpecify env mode (default: development).
--host0.0.0.0Specify host (default: 0.0.0.0).
--port8080Specify port (default: 8080).
--httpsfalseUse https (default: false).
--public-Specify the public network URL for the HMR client.
--skipPlugins-Comma-separated list of plugin names to skip for this run.
--browserTarget-Target to serve.
--watchtrueWatch for changes.
--publicPath/The base URL your application bundle will be deployed at.
--transpileDependencies[]By default babel-loader ignores all files inside node_modules. If you want to explicitly transpile a dependency with Babel, you can list it in this option.
css.extractfalseWhether to extract CSS in your components into a standalone CSS file (instead of inlined in JavaScript and injected dynamically).
css.sourceMapfalseWhether to enable source maps for CSS. Setting this to true may affect build performance.
css.loaderOptions{}Pass options to CSS-related loaders.
devServer{}All options for webpack-dev-server are supported.

Browser

nx build <name> [options]

ArgumentsDescription
<name>The name of your app.
OptionsDefaultDescription
--modedevelopmentSpecify env mode (default: development).
--dest-Specify output directory.
--cleantrueRemove the dist directory before building the project.
--reportfalseGenerate report.html to help analyze bundle content.
--reportJsonfalseGenerate report.json to help analyze bundle content.
--skipPlugins-Comma-separated list of plugin names to skip for this run.
--watchfalseWatch for changes.
--index-The path of a file to use for the application's HTML index. The filename of the specified path will be used for the generated file and will be created in the root of the application's configured output path.
--main-The full path for the main entry point to the app, relative to the current workspace.
--tsConfig-The full path for the TypeScript configuration file, relative to the current workspace.
--publicPath/The base URL your application bundle will be deployed at.
--filenameHashingfalseGenerated static assets contain hashes in their filenames for better caching control.
--productionSourceMapfalseSetting this to false can speed up production builds if you don't need source maps for production.
--transpileDependencies[]By default babel-loader ignores all files inside node_modules. If you want to explicitly transpile a dependency with Babel, you can list it in this option.
css.extractfalseWhether to extract CSS in your components into a standalone CSS file (instead of inlined in JavaScript and injected dynamically).
css.sourceMapfalseWhether to enable source maps for CSS. Setting this to true may affect build performance.
css.loaderOptions{}Pass options to CSS-related loaders.
--stdinfalseClose when stdin ends.

Library

nx build <name> [options]

ArgumentsDescription
<name>The name of your library.
OptionsDefaultDescription
--dest-Specify output directory.
--cleantrueRemove the dist directory before building the project.
--reportfalseGenerate report.html to help analyze bundle content.
--reportJsonfalseGenerate report.json to help analyze bundle content.
--skipPlugins-Comma-separated list of plugin names to skip for this run.
--watchfalseWatch for changes.
--entry-The full path for the main entry point to your library, relative to the current workspace.
--tsConfig-The full path for the TypeScript configuration file, relative to the current workspace.
--inlineVuefalseInclude the Vue module in the final bundle of library.
--formatscommonjs,umd,umd-minList of output formats for library builds.
--name-Name for library.
--filename-File name for output.
--transpileDependencies[]By default babel-loader ignores all files inside node_modules. If you want to explicitly transpile a dependency with Babel, you can list it in this option.
css.extracttrueWhether to extract CSS in your components into a standalone CSS file (instead of inlined in JavaScript and injected dynamically).
css.sourceMapfalseWhether to enable source maps for CSS. Setting this to true may affect build performance.
css.loaderOptions{}Pass options to CSS-related loaders.

Linting

nx lint <name> [options]

We use @nrwl/linter for linting, so the options are as documented here.

Unit Testing

nx test <name> [options]

We use @nrwl/jest for unit testing, so the options are as documented here.

E2E Testing

nx e2e <name> [options]

We use @nrwl/cypress for e2e testing, so the options are as documented here.

Modify the Webpack Configuration

Modify the webpack config by exporting an Object or Function from your project's configure-webpack.js file.

If your project does not have a configure-webpack.js file, then simply add it at the root of your project.

If the value is an Object, it will be merged into the final config using webpack-merge.

If the value is a function, it will receive the resolved config as the argument. The function can either mutate the config and return nothing, OR return a cloned or merged version of the config.

For more information see the Vue CLI documentation.

Updating Nx Plus Vue

Nx Plus Vue provides migrations which help you stay up to date with the latest version of Nx Plus Vue.

Not only do we migrate the version of Nx Plus Vue, but we also update the versions of dependencies which we install such as vue and vue-router.

We recommend waiting for Nx Plus Vue to update these dependencies for you as we verify that these versions work together.

How to Migrate

Generate migrations.json

All you have to do to update Nx Plus Vue to the latest version is run the following:

nx migrate @nx-plus/vue
nx migrate @nx-plus/vue@version # you can also specify version

This will fetch the specified version of @nx-plus/vue, analyze the dependencies and fetch all the dependent packages. The process will keep going until the whole tree of dependencies is resolved. This will result in:

  • package.json being updated
  • migrations.json being generated

At this point, no packages have been installed, and no other files have been touched.

Now, you can inspect package.json to see if the changes make sense and install the packages by running npm install or yarn.

Run Migrations

migrations.json contains the transformations that must run to prepare the workspace to the newly installed versions of packages. To run all the migrations, invoke:

nx migrate --run-migrations=migrations.json
15.0.0-rc.0

1 year ago

14.1.0

2 years ago

13.0.2

2 years ago

14.0.0

2 years ago

13.0.0

2 years ago

13.0.1

2 years ago

12.2.0

3 years ago

12.1.0

3 years ago

12.0.0

3 years ago

11.0.1

3 years ago

11.0.0

3 years ago

10.4.0

3 years ago

10.3.0

3 years ago

10.2.0

4 years ago

10.1.0

4 years ago

10.0.0

4 years ago

0.6.0

4 years ago

0.5.0

4 years ago

0.4.1

4 years ago

0.4.0

4 years ago

0.3.0

4 years ago

0.2.0

4 years ago

0.1.0

4 years ago