我是 Sails 的新手。
我从 Sails 模板创建了一个新的网络应用程序,并尝试将其上传到 Heroku。除了资产之外,一切都很好,没有找到任何资产(js、css、图像等)。
我发现 Sails 使用 Grunt 将文件复制到 .tmp 文件夹。我已经检查过并将 Grunt 添加到我的package.json文件中。我还在Heroku 中添加了一个带有web: node app.js命令和NODE_ENV它指向的变量的 Procfile production。
我没有改变任何 Grunt 任务,Gruntfile.js文件和/tasks目录都是默认的。
还有什么我可以检查的想法吗?
小智 7
我通过不同的方式解决了这个问题。除了grunt在 OP 的答案中包含一些deps 之外,我postinstall还在以下脚本部分添加了package.json:
"scripts": {
"start": "NODE_ENV=production node app.js",
"test": "npm run lint && npm run custom-tests && echo 'Done.'",
"lint": "eslint . --max-warnings=0 --report-unused-disable-directives && echo '? Your .js files look so good.' && htmlhint -c ./.htmlhintrc views/*.ejs && htmlhint -c ./.htmlhintrc views/**/*.ejs && htmlhint -c ./.htmlhintrc views/**/**/*.ejs && htmlhint -c ./.htmlhintrc views/**/**/**/*.ejs && htmlhint -c ./.htmlhintrc views/**/**/**/**/*.ejs && htmlhint -c ./.htmlhintrc views/**/**/**/**/**/*.ejs && htmlhint -c ./.htmlhintrc views/**/**/**/**/**/**/*.ejs && echo '? So do your .ejs files.' && lesshint assets/styles/ --max-warnings=0 && echo '? Your .less files look good, too.'",
"custom-tests": "echo \"(No other custom tests yet.)\" && echo",
"postinstall": "grunt build", // added this
...
Run Code Online (Sandbox Code Playgroud)
这在Heroku上的效果是需要的繁重任务的运行build,其编译和资产复制到适当引用的位置(即:.tmp)
| 归档时间: |
|
| 查看次数: |
603 次 |
| 最近记录: |