Compile less files and minify js files in node.js project on AWS Elastic Beanstalk

a 夏天 提交于 2019-12-08 02:27:32

问题


I am using the Eb Command Line Interface to deploy a node.js project to AWS Elastic Beanstalk. I am using git for version control. So the command I run to deploy is simply 'git aws.push'. Locally, I am using grunt to compile css files from less files and also minify and cmobine js files.

I don't want to include the *.min.css files or *.min.js files in my git repository but would rather have them recompiled on AWS after deployment. Is there a way to do this? Maybe with a .ebextensions hook or something?


回答1:


I am not familiar with grunt, but I guess what you would have to do is install nodejs and grunt on elastic beanstalk and then running your grunt commands once the container is set up.

In a ebextensions hook such as .ebextensions/grunt.config you could do the following :

commands:
  01-install-nodejs-npm:
    command: "yum install -y --enablerepo=epel nodejs npm"
  02-install-grunt:
    command: "npm install -g grunt-cli"

container_commands:
  01-compilecss-minifyjs:
    command: "grunt build mytask"
    leader_only: true

The commands would make sure nodejs, npm and grunt are installed. The container_commands are executed from within your repository's home directory, so the "source" files for your grunt build should be available from there.

Again - I don't work with grunt and can't tell if this would actually work, but I hope it helps anyway.



来源:https://stackoverflow.com/questions/21246882/compile-less-files-and-minify-js-files-in-node-js-project-on-aws-elastic-beansta

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!