그래서 제대로 작동하지만 더 나은 솔루션을 제공 할 수 있습니다.
"Main"과 "Frontend"프로젝트 (Main의 Git 하위 모듈)를 호출 할 것입니다. 대부분의 설정은 Main에 있었으며, 앞으로도 유사한 설치를 더 쉽게하기 위해 피하고 싶습니다. 그러나 지금은이를 구현하는 방법을 모르겠습니다.
나는 3 주에 buildpacks 추가 :;
heroku/ruby
heroku/nodejs
(그런트 지원) (나침반 지원, 그렇지 않으면 필요하지 않음), 및
heroku/python
을 (메인은 플라스크 프로젝트이기 때문에) : 다음
heroku buildpacks:clear &&
heroku buildpacks:add heroku/ruby &&
heroku buildpacks:add heroku/nodejs &&
heroku buildpacks:add heroku/python
, I 홈페이지에 Gemfile
을 추가 : 당신이 bootstrap-sass
를 사용하지 않는 경우
source "https://rubygems.org"
gem 'sass', "3.4.23"
gem 'compass', "1.0.3"
gem 'bootstrap-sass', "3.3.7"
마지막 줄은 필요하지 않습니다.
또한 Gemfile.lock
이 필요하며 bundle check
, bundle install
및 bundle update
으로 확인/생성/새로 고침 할 수 있습니다. (this example 다음 만든)
우리는 정말로 홈페이지에 그런트 처리를 필요로하지 않지만, 우리는 여전히 서브 모듈의 처리를 호출하기 위해 홈페이지에 Gruntfile.js
이 필요합니다
module.exports = function(grunt) {
grunt.registerTask('buildapp', function(dir) {
var done = this.async();
var done_or_error = function(err, result, code) {
if (err == null) {
grunt.log.writeln(result);
grunt.log.writeln('processed ' + dir);
done();
}
else {
grunt.log.writeln('processing ' + dir + ' failed: ' + code);
grunt.log.writeln(' ERR: ' + err);
grunt.log.writeln(' RESULT: ' + result);
done(false);
}
};
grunt.log.writeln('processing ' + dir);
grunt.util.spawn(
{
cmd: 'npm',
args: ['install'],
opts: {
cwd: dir,
},
},
done_or_error
);
});
grunt.registerTask('build', function() {
grunt.task.run(['buildapp:server/shared']);
});
grunt.registerTask('heroku', ['build']);
};
자신의 메인이 이미있는 경우 그런 다음 Grunt를 사용하여 위의 내용을 작업에 추가 할 수 있습니다.
가 자동으로 실행이 얻을 홈페이지에
package.json
를 만들려면 :
이
{
"name": "...",
"version": "...",
"dependencies": {
"compass": "^0.1.1",
"grunt": "^0.4.5",
"grunt-cli": "^1.2.0",
"grunt-util-spawn": "0.0.2"
},
"engines": {
"node": "8.4.0"
},
"scripts": {
"postinstall": "grunt heroku"
}
}
여기서 중요한 부분은 grunt heroku
이다. 나머지는 단지 내 의존성 일 뿐이며, 당신과 다를 수 있습니다.
위 내용은 npm install
을 프론트 엔드에 트리거합니다. 뿐만 아니라 하나 개 실행 프론트 엔드의 그런트이 프런트 엔드의 package.json
에 "scripts"
에
"postinstall": "grunt ..."
을 추가합니다. 이것은 보통 프론트 엔드를 수동으로 구축하는 방법입니다 (제 경우에는 전체 명령은 grunt deploy --target production
입니다).
생성 된 파일을 .gitignore
에 추가하는 것을 잊지 마세요.
/node_modules
gen
/dist
/static/css
이상적으로 당신은 GRUN 생성 된 파일과 하나의 디렉토리 (I 인해 기존에 몇 가지있다을 가지고 프로젝트를 설정합니다, 내 프론트 엔드 것이있는 동안 내 홈페이지의 경우, 단지 /node_modules
입니다 원인).