Skip to content

feat: pass current CLI public lib path to webpack env #5381

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 8, 2020

Conversation

rigor789
Copy link
Member

@rigor789 rigor789 commented Sep 8, 2020

PR Checklist

What is the current behavior?

There is currently no way to get values from the nativescript.config.ts file in the webpack config unless you use a .js config file.

What is the new behavior?

With this change, the path to the nativescript lib (exposing the public API of the CLI) is passed to the webpack env, and the webpack config can read useful data from the CLI - inlcluding values from a ts config file. For example, the following would get the values from the nativescript.config.ts (or .js).

const nativescriptLib = require(env.nativescriptLibPath)
const nsConfig = nativescriptLib.projectDataService.getProjectData().nsConfig
console.log(nsConfig)

Or even using the config service directly:

const nativescriptLib = require(env.nativescriptLibPath)
console.log(nativescriptLib.projectConfigService.readConfig())
console.log(nativescriptLib.projectConfigService.getValue('id'))
// setValue is also exported for updating the config!

/cc @farfromrefug

@cla-bot cla-bot bot added the cla: yes label Sep 8, 2020
@rigor789 rigor789 merged commit 6f91984 into master Sep 8, 2020
@rigor789 rigor789 deleted the feat/webpack-nativescript-lib-path branch September 8, 2020 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants