I have multiple webpack file with different 'purpose' and before and I need to run different webpack tasks, for example:
package.json:
"scripts": {
"webpack-dll": "set NODE_ENV=dll && webpack",
"webpack-admin": "set NODE_ENV=admin && webpack",
"webpack-dev": "set NODE_ENV=dev && webpack"
}
Before build I want to run 'dll' 'admin' and 'dev' task. But I can't bind more than one task to before build section.
Is there any solution to solve this?
Thanks.
You can create another entry in the scripts section in package.json and call that.
"scripts": {
"webpack-dll": "set NODE_ENV=dll && webpack",
"webpack-admin": "set NODE_ENV=admin && webpack",
"webpack-dev": "set NODE_ENV=dev && webpack",
"before-build: "npm run webpack-dll && npm run webpack-admin && npm run webpack-dev"
}
Another option is to add the npm-run-all package. Then you can run the tasks in parallell like this:
"scripts": {
"webpack-dll": "set NODE_ENV=dll && webpack",
"webpack-admin": "set NODE_ENV=admin && webpack",
"webpack-dev": "set NODE_ENV=dev && webpack",
"before-build: "run-p webpack-dll && npm run webpack-admin && npm run webpack-dev"
}