Task for deploying ?
I'm a bit lost with deployment with Webstorm.
Basically, I have a dist/ folder where I put my compiled stuff that's ready to deploy. I will run an npm run script that uses webpack to compile my Typescript code and bundle it into a client.js file, together with a index.html file depending on the javascript file.
I created a simple NPM task for this in Webstorm and it works fine, putting the files in my dist/ folder.
Now I want to deploy these files onto my production server. Obviously I can use scp or whatever in my terminal, but I would like to do it through Webstorm (so that I can take advantage of the shortcuts). Two questions :
- Is it possible to do that through Webstorm ? The only thing I found was the Deployment feature, but it requires me to select my dist/ folder then to Deploy to server. I would like to avoid having to select dist/ every time, since I have a rather vast filetree and it's just pointless. I always want Deployment to deploy my dist/folder and nothing else, is there a way to make it the default behaviour and avoid having to select the folder manually every time ?
- Is it possible to automate the deployment AFTER my npm task ? Like, as soon as my NPM task is over (everything is build and in dist/), deploy what's inside dist/ ? In the NPM task I can only pick Before Launch actions, not "After Launch" ones.
Also, maybe I'm going the wrong way about deploying to prod, so don't hesitate if you have advice/tips about how to streamline the building and deployment process, I'm fairly new to web dev. I just want my deployment process to be streamlined, building followed by an automatic upload of the right files into the right place on my server.
Thanks in advance !
Please sign in to leave a comment.
It's possible using Deployment - you can set up the server in Settings | Build, Execution, Deployment | Deployment and enable auto-synchronization. See https://confluence.jetbrains.com/display/PhpStorm/Deployments+in+PhpStorm for more info
Hello Elena,
I'm already using Deployment on Webstorm, the issue/question is twofold :
- Is there a way to deploy a specific folder/files without having to select them every time I want to deploy them ? When I press the deployment button (or shortcut) it tries to deploy the file I'm currently editing, while I'd like it to deploy my dist folder. I can't use auto-synchronization because I want to deploy to production, and auto-synchronizing is way too risky for that. I want to control when it's deployed myself, not everytime I build the dist/ folder.
- Is there a way to create a run configuration for Deployment and/or set it as an "After launch" task on a configuration ? I can do it on a "Before launch" task but it's of no use to me, I want to deploy after running my build configuration.
And bonus question, I exclude my dist/ folder from my project (with right click -> mark as -> excluded) so that Webstorm does not index the files in it, nor take them into account for refactoring. This means that I can't set my dist/ folder as the root folder for Deployment, which is problematic. Any way around that ? I have to set the parent directory as root folder, and parent directory contains my whole project (source code, config stuff, etc) that I don't want to Deploy. Obviously I can just add everything to the exclude tab of the Deployment, except the dist/ folder, but that's quite bothersome.
Thanks
>Is there a way to deploy a specific folder/files without having to select them every time I want to deploy them ?
No; please follow https://youtrack.jetbrains.com/issue/WI-24735, https://youtrack.jetbrains.com/issue/WI-15232 and linked tickets for updates.
You can add all paths except for dist to Excluded to make sure that only dist is deployed - see https://confluence.jetbrains.com/display/PhpStorm/Deploying+PHP+applications+with+PhpStorm#DeployingPHPapplicationswithPhpStorm-1.5.(optional)Configureexcludedpaths
>Is there a way to create a run configuration for Deployment and/or set it as an "After launch" task on a configuration ? I can do it on a "Before launch" task but it's of no use to me, I want to deploy after running my build configuration.
No way:( Please vote for https://youtrack.jetbrains.com/issue/IDEA-132501 and https://youtrack.jetbrains.com/issue/WI-3239