Setup custom config.json location for Grunt tasks in IntelliJ IDEA - intellij-idea

I want to run my Grunt tasks (through a GruntFile.js file) in my IntelliJ IDEA. However, the config.json is located somewhere else which is causing the loading of the GruntFile.js to crash.
Is there a way to set the –-config.json parameter? Or is there a work around? It seems that I only can configure the environment variables and node options.

We configured a custom environment variable. It works beautifully.
grunt.option('config.json') || process.env.BS_CONFIG_JSON|| 'build/config.json'

Related

How do I import variables from .env in Intellij IDEA Protractor (JS) debug?

I have recently introduced a .env file to a Typescript Protractor project. I installed dotenv package, and run dotenv.config() at the very top of the protractor config file. When executed from console, all works as expected, .env is loaded, everyone's happy.
However when I execute from IntelliJ IDEA's debug tool (configured for Protractor), the .env file doesn't load - even though the code goes through dotenv.config().
I can work around by setting env variables in the debug config, but that has to be done manually, and I would prefer to source these values from the .env file automatically (source .env in a "before launch" script doesn't help either).
Can this be done using just Cucumber.js package? If not, which package would help?

Application environment variables undefined when application is served by Amplify

I have a Vue.js app hosted by AWS Amplify.
In Vue, env vars can be set application-wide by using .env. files.
I currently use such files for development and for production modes, containing different values.
When locally building and serving my application the above works as expected. However, once Amplify deploys my app (in my case I use Amplify's CD feature), these variables are not defined.
I know I can define the same env vars in Amplify, but that would mean I need to manage these values in two places since won't be redeploying while developing. so this seems to be prone to errors (I will need to remember to update the vars on both the application end and amplify console whenever I need to make a change for example).
I wonder if this behavior is expected or is there something I am missing in my setup.
Thanks!
I was also facing the same issue in my React app.
The thing is, you need to have a .env file in your app with all the environment variables.
Why? — The reason behind that is, it generates static HTML, CSS and JS files. Those files can't access process during the runtime.
After adding all the environment variables in Amplify, you have to add one more command in your build stage in App build specification.
You can refer to this official documentation on how to implement this.
If you don't care much about your environment variables, you can use this hack: printenv. This will store all the environment variables of your OS and your application in the .env file.
My config looks something like this:
build:
commands:
- 'printenv >> .env'
- 'npm run build'

WebStorm run configuration - package.json path relative to project directory

Question: In WebStorm's npm run configuration: How to make the package.json path relative to project directory?
Goal: To be able to share the run configuration in VCS, it must not depend on where the project is on my machine.
Screenshot: I.e., I want to change ~\WebStormProjects\x-nest\ to PROJECT_DIR\.
package.json field doesn't support variables; but you do not need to use macros or do anything at all to make configurations shareable, this case is handled automatically: if you look inside the .idea/workspace.xml (or .idea\runConfigurations\<config name>.xml if Share through VCS is enabled for it) file you'll notice that IDE stores this path as $PROJECT_DIR$/path/to/package.json, like:
<package-json value="$PROJECT_DIR$/package.json" />
So you can safely keep this .xml file under Version Control and your colleagues will have the correct path to the file even if local path to project is different.

Vue webpack environment variables configuration

I am new to vue in general and i am trying to configure some environment variables for some projects of mine so i can do some tests with cookies but apperently i ran the simple webpack configurations when creating these projects, therefore i dont have access to the config directory to edit said variables.
I created a vue.config.js file and used the following lines:
module.exports = {
publicPath: 'myAppName'
}
However if i run it on development mode, or simply use npm run serve my app runs at "http://localhost:8080/myAppName" instead of simply "myAppName".
How do i correctly configure my environment variables for my projects without having to start over from scratch? I am using vueCli 3 btw.
I tried following these examples but none have worked:
Using Environment Variables with Vue.js
I also have .env file and a .env.development file but i am not sure what to add to it.

IntelliJ & Global Config Files

I've been searching for a solution but I can't find one.
I have a global configuration directory in my IntelliJ workspace. I also have several dozen modules. I would like each module to automatically include the global config directory in its path when I run or test a class.
Is there anyway to do this within IntelliJ? I don't think I should need to edit the configuration for each "Run/Debug" config to include the directory.
You'll want to set it in the Defaults for the type of Run or Debug Configuration that you are using.
For example, if I always want a Java Application to have the VM Option -XPutYourThingyHere, then I could go to Edit Configurations, Defaults, Application, and put -XPutYourThingyHere in the VM Options box. Then all new Applications that I run will have that option.