Good day to all! I make a web application on Angular 2. I wanted to automate deploy by ftp. To build using Webpack. There is information that node.js itself can help in solving the problem, there is an example script. But how to make the necessary script run after executing the npm run build command? As I understand it, you need to add a script call to the scripts section of the package.json file. Or am I wrong? The scripts section of the package.json file.

"scripts": { "clean": "rimraf node_modules doc dist && npm cache clean", "clean-install": "npm run clean && npm install", "clean-start": "npm run clean-install && npm start", "watch": "webpack --watch --progress --profile", "build": "rimraf dist && webpack --progress --profile --bail", "server": "webpack-dev-server --inline --progress --port 8080", "webdriver-update": "webdriver-manager update", "webdriver-start": "webdriver-manager start", "lint": "tslint --force \"src/**/*.ts\"", "e2e": "protractor", "e2e-live": "protractor --elementExplorer", "pretest": "npm run lint", "test": "karma start", "posttest": "remap-istanbul -i coverage/json/coverage-final.json -o coverage/html -t html", "test-watch": "karma start --no-single-run --auto-watch", "ci": "npm run e2e && npm run test", "docs": "typedoc --options typedoc.json src/app/app.component.ts", "start": "npm run server", "start:hmr": "npm run server -- --hot", "postinstall": "npm run webdriver-update", }, 

Thanks for the help.

    2 answers 2

    If you already have a script for deployment , then you can add a separate entry for it in the scripts , as well as create a unified command for sequential building and unloading the project:

     "scripts": { "deploy": "<здесь вы вызываете CLI команду для выгрузки готового приложения>", "build": "rimraf dist && webpack --progress --profile --bail", "build-n-deploy": "npm run build && npm run deploy" }, 

    Here is an example of the build with the deployment:

     npm run build-n-deploy 
    • Dmitry, thanks to the help, in general, your advice and worked - created a Node-module ftp-deployment and hooked it to the assembly team. Everything turned out to be simple. There were just thoughts about the variant via Git-hook, but in my project conditions it would not work in the end. For the sake of the latter, I had to study Git, and this turns out to be a whole world :-) - Andrew

    If you have git. You can set globally valid npm git-pull-all .

    and in package.json add something like this to the script:

     "scripts": { ... git_pull:'git-pull-all ./' } 

    Because npm install and in theory should work pouring on all branches and folders