teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

4

2017/02/08 03:12

投稿

philomagi
philomagi

スコア267

title CHANGED
File without changes
body CHANGED
@@ -11,6 +11,7 @@
11
11
  リポジトリから再クローンしてからビルドを実行してみたのですが、やはりローカルでは成功してしまいます。
12
12
 
13
13
  Heroku上でのみビルドが失敗する原因について、何か心当たりが有る方ご教授いただけないでしょうか。
14
+ 開発環境はMacOSです。
14
15
 
15
16
  以下にpackage.json、gulpfile.jsのビルドに関する部分の抜粋、gulpfileが参照しているjson、bower.jsonを記載します。
16
17
  Herokuおよびローカルで試したコマンドはいずれも`npm run build`です。

3

設定ファイルの内容を記載

2017/02/08 03:12

投稿

philomagi
philomagi

スコア267

title CHANGED
File without changes
body CHANGED
@@ -10,4 +10,238 @@
10
10
  ローカルでも試してみたのですが、ローカルでは何の問題もなくビルドが成功してしまうため、手がかりをつかめずにいます。
11
11
  リポジトリから再クローンしてからビルドを実行してみたのですが、やはりローカルでは成功してしまいます。
12
12
 
13
- Heroku上でのみビルドが失敗する原因について、何か心当たりが有る方ご教授いただけないでしょうか
13
+ Heroku上でのみビルドが失敗する原因について、何か心当たりが有る方ご教授いただけないでしょうか
14
+
15
+ 以下にpackage.json、gulpfile.jsのビルドに関する部分の抜粋、gulpfileが参照しているjson、bower.jsonを記載します。
16
+ Herokuおよびローカルで試したコマンドはいずれも`npm run build`です。
17
+
18
+ ###package.json
19
+
20
+ ```
21
+ {
22
+ "name": "myapp",
23
+ "version": "0.1.0",
24
+ "description": "A Vue.js project",
25
+ "author": "",
26
+ "private": true,
27
+ "scripts": {
28
+ "postinstall": "bower install && npm run build",
29
+ "watchify": "gulp watchify --env=$NODE_ENV --api=$API_URL",
30
+ "lint:vue": "gulp lint:vue",
31
+ "test": "karma start karma.conf.js",
32
+ "build": "gulp build --env=$NODE_ENV --api=$API_URL",
33
+ "gulp": "gulp --env=$NODE_ENV --api=$API_URL"
34
+ },
35
+ "browserify": {
36
+ "transform": [
37
+ "babelify",
38
+ "debowerify",
39
+ "vueify"
40
+ ]
41
+ },
42
+ "browser": {
43
+ "vue": "vue/dist/vue.common"
44
+ },
45
+ "dependencies": {
46
+ "axios": "^0.15.3",
47
+ "babel-core": "^6.0.0",
48
+ "babel-plugin-transform-inline-environment-variables": "^6.8.0",
49
+ "babel-plugin-transform-object-rest-spread": "^6.20.2",
50
+ "babel-plugin-transform-runtime": "^6.0.0",
51
+ "babel-preset-es2015": "^6.0.0",
52
+ "babel-preset-stage-2": "^6.0.0",
53
+ "babel-runtime": "^6.0.0",
54
+ "babelify": "^7.2.0",
55
+ "bootstrap-sass": "^3.3.7",
56
+ "bower": "^1.8.0",
57
+ "browserify": "^13.1.0",
58
+ "browserify-hmr": "^0.3.1",
59
+ "cross-env": "^2.0.0",
60
+ "css-loader": "^0.26.1",
61
+ "debowerify": "^1.5.0",
62
+ "envify": "^3.4.1",
63
+ "express": "^4.14.0",
64
+ "gentelella": "^1.3.0",
65
+ "gulp": "^3.9.1",
66
+ "gulp-autoprefixer": "^3.1.1",
67
+ "gulp-env": "^0.4.0",
68
+ "gulp-envify": "^1.0.0",
69
+ "gulp-sass": "^2.3.2",
70
+ "gulp-sourcemaps": "^2.2.0",
71
+ "gulp-uglify": "^2.0.0",
72
+ "gulp-util": "^3.0.8",
73
+ "gulp-vueify": "0.0.3",
74
+ "gulp-webserver": "^0.9.1",
75
+ "marked": "^0.3.6",
76
+ "minimist": "^1.2.0",
77
+ "moment": "^2.17.1",
78
+ "node-sass": "^3.13.1",
79
+ "uglify-js": "^2.5.0",
80
+ "vinyl-buffer": "^1.0.0",
81
+ "vinyl-source-stream": "^1.1.0",
82
+ "vue": "^2.1.6",
83
+ "vue-datepicker": "https://github.com/hilongjw/vue-datepicker.git",
84
+ "vue-indicator": "0.0.7",
85
+ "vue-resource": "^1.0.3",
86
+ "vue-router": "^2.0.1",
87
+ "vue-template-compiler": "^2.1.6",
88
+ "vue2-timepicker": "^0.1.4",
89
+ "vueify": "^9.4.0",
90
+ "vuex": "^2.1.1"
91
+ },
92
+ "devDependencies": {
93
+ "babel-eslint": "^7.1.1",
94
+ "eslint": "^3.3.0",
95
+ "eslint-config-standard": "^5.3.5",
96
+ "eslint-config-vue": "^2.0.1",
97
+ "eslint-plugin-html": "^1.5.2",
98
+ "eslint-plugin-promise": "^2.0.1",
99
+ "eslint-plugin-standard": "^2.0.0",
100
+ "eslint-plugin-vue": "^1.0.0",
101
+ "gulp-eslint": "^3.0.1",
102
+ "gulp-plumber": "^1.1.0",
103
+ "jasmine-core": "^2.4.1",
104
+ "karma": "^1.2.0",
105
+ "karma-browserify": "^5.1.0",
106
+ "karma-jasmine": "^1.0.2",
107
+ "karma-phantomjs-launcher": "^1.0.0",
108
+ "karma-spec-reporter": "0.0.26",
109
+ "npm-run-all": "^2.3.0",
110
+ "phantomjs-prebuilt": "^2.1.3",
111
+ "proxyquireify": "^3.0.1",
112
+ "watchify": "^3.4.0"
113
+ }
114
+ }
115
+
116
+ ```
117
+
118
+ ###gulpfile.js
119
+ gulpfileではminimistを使って、引数のenvとapiをargvという変数に格納しています。
120
+ ```javascript
121
+ // 本番環境とローカル環境で、APIコールの向き先を変えている
122
+
123
+ var path = {
124
+ vue: (app) => {
125
+ return {
126
+ src: `./client/view/${app}/src/main.js`,
127
+ out: `./public/${app}/`
128
+ };
129
+ }
130
+ };
131
+ require('gulp-env')({
132
+ vars: {
133
+ NODE_ENV: argv.env || 'development',
134
+ API_URL: argv.api || 'http://localhost:8080'
135
+ }
136
+ });
137
+
138
+ var isProduction = argv.env === 'production';
139
+
140
+ gulp.task('build', [
141
+ 'build:vue',
142
+ 'build:sass', // sassファイルのコンパイル
143
+ 'build:static' // 画像やhtmlを公開フォルダにコピー
144
+ ]);
145
+
146
+ gulp.task('build:vue', () => {
147
+ // 公開ページと管理ページ等、複数のシングルページ用ソースをまとめてビルドする。
148
+ // applicationsに入っているのは、各アプリ名となる文字列
149
+ applications.forEach(function(app) {
150
+ console.log(`build:vue:${app}`);
151
+ rebuild(app, false);
152
+ });
153
+ });
154
+
155
+ function rebuild(app, isWatch) {
156
+ var browserify = require('browserify'),
157
+ source = require('vinyl-source-stream'),
158
+ uglify = require('gulp-uglify'),
159
+ buffer = require('vinyl-buffer'),
160
+ vuePath = path.vue(app), // 各アプリのパスを取得
161
+ browserifyHmr = require('browserify-hmr'),
162
+ b = browserify(vuePath.src, {
163
+ paths: require('./.localmodules.json')
164
+ });
165
+
166
+ if(!isProduction && isWatch) {
167
+ // watchifyは開発環境でしか使わない + インストールしない
168
+ const watchify = require('watchify');
169
+ b = watchify(b).plugin(browserifyHmr);
170
+ }
171
+
172
+ b.plugin('vueify/plugins/extract-css', { out: vuePath.out + 'build.css' })
173
+ .on('update', () => {
174
+ exec();
175
+ })
176
+ .on('error', (e) => {
177
+ console.log(e);
178
+ })
179
+ .on('log', (message) => {
180
+ console.log(message);
181
+ });
182
+
183
+ return exec();
184
+
185
+ function exec(bundler) {
186
+ if(!isProduction) {
187
+ eslint(app); // lintチェック
188
+ }
189
+
190
+ (() => {
191
+ if(!isProduction && isWatch) {
192
+ var plumber = require('gulp-plumber');
193
+ return b.bundle().pipe(plumber(plumberConfig(`build:vue:${app}`)));
194
+ }
195
+ return b.bundle();
196
+ })().on('error', (e) => {
197
+ util.log(util.colors.red('[Error][bundle]'), e.message);
198
+ util.log(util.colors.red('[Error][bundle]'), e);
199
+ })
200
+ .pipe(source('build.js'))
201
+ .pipe(buffer())
202
+ .pipe(sourcemap.init())
203
+ .pipe(uglify().on('error', function(err) {
204
+ util.log(util.colors.red('[Error][uglify]'), err.message);
205
+ this.emit('end');
206
+ }))
207
+ .pipe(sourcemap.write())
208
+ .pipe(gulp.dest(vuePath.out));
209
+ }
210
+ }
211
+ ```
212
+
213
+ ###.localmodules.json
214
+
215
+ ```
216
+ [
217
+ "./node_modules",
218
+ "./bower_components",
219
+ "./client"
220
+ ]
221
+ ```
222
+
223
+ ###bower.json
224
+
225
+ ```
226
+ {
227
+ "name": "myapp",
228
+ "description": "",
229
+ "main": "",
230
+ "license": "MIT",
231
+ "homepage": "",
232
+ "private": true,
233
+ "ignore": [
234
+ "**/.*",
235
+ "node_modules",
236
+ "bower_components",
237
+ "test",
238
+ "tests"
239
+ ],
240
+ "dependencies": {
241
+ "AdminLTE": "admin-lte#^2.3.11",
242
+ "summernote": "^0.8.2",
243
+ "jquery": "^3.1.1"
244
+ }
245
+ }
246
+
247
+ ```

2

タイトル・文言修正

2017/02/07 15:32

投稿

philomagi
philomagi

スコア267

title CHANGED
@@ -1,1 +1,1 @@
1
- ローカルでは成功するHerokuでbrowserify失敗する
1
+ Herokuへデプロイ時、browserifyでCan not find module となって失敗する
body CHANGED
@@ -8,5 +8,6 @@
8
8
  App.vue内で`import MyComp from './comp/MyComponent.vue'`として利用しようとしているのですが、そこで見つからないとしてエラーにされてしまっているようです。
9
9
 
10
10
  ローカルでも試してみたのですが、ローカルでは何の問題もなくビルドが成功してしまうため、手がかりをつかめずにいます。
11
+ リポジトリから再クローンしてからビルドを実行してみたのですが、やはりローカルでは成功してしまいます。
11
12
 
12
- ソースコード、gulp、あるいはその他設定ファイルをどのように修正すれば良でしょうか
13
+ Heroku上でのみビルが失敗する原因について何か心当たりが有方ご教授ただけないでしょうか

1

typo修正

2017/02/06 11:52

投稿

philomagi
philomagi

スコア267

title CHANGED
File without changes
body CHANGED
@@ -1,4 +1,4 @@
1
- Vue.jsを使ったクライアントサイドのアプリケーションを個人的に組んでいるのですが、最近諸々の機能追加をしたソースコードをHerokuへデプロイしようとしたところ、イカのエラーメッセージがgulpから出ました。
1
+ Vue.jsを使ったクライアントサイドのアプリケーションを個人的に組んでいるのですが、最近諸々の機能追加をしたソースコードをHerokuへデプロイしようとしたところ、以下のエラーメッセージがgulpから出ました。
2
2
  ```
3
3
  Cannot find module './comp/MyComponent.vue' from '/tmp/build_d491e7aeb055a2fa8d60a2b6bd7a2290/client/view/myapp/src/components/contents/
4
4
  ```