How to deploy a vuejs (browserify) application in heroku?

0

I raised the server with express , however using a schema for webpack because I did not find anything related to browserify , follow the code ...

// server.js
var express = require('express');
var path = require('path');
var serveStatic = require('serve-static');
app = express();
app.use(serveStatic(__dirname + "/dist"));
var port = process.env.PORT || 5000;
app.listen(port);
console.log('server started '+ port);

everything is set up correctly, but it is only appearing ...

  

Can not GET /

Does anyone know how I can do this?

package.json

"scripts": {
    "watchify": "watchify -vd -p browserify-hmr -e src/main.js -o dist/build.js",
    "serve": "http-server -o -s -c 1 -a localhost",
    "dev": "npm-run-all --parallel watchify serve",
    "build": "cross-env NODE_ENV=production browserify -g envify src/main.js | uglifyjs -c warnings=false -m > dist/build.js",
    "postinstall": "npm install express",
    "start" : "node server.js"
  },

With the command that is in start the server raises, however the application is not found.

Obs. to start it locally you need a npm run dev that could not be executed in start in heroku.

    
asked by anonymous 21.12.2017 / 16:19

1 answer

1

As you are using http-server as a server, one option is to run npm-run-all in start and to host in Heroku omit the host. With these changes the app will be interpreted:

{
  "name": "teste",
  "description": "primeiro projeto em vue",
  "author": "teste",
  "private": true,
  "scripts": {
    "watchify": "watchify -vd -p browserify-hmr -e src/main.js -o dist/build.js",
    "serve": "http-server -o -s -c 1 -a",
    "dev": "npm-run-all --parallel watchify serve",
    "build": "cross-env NODE_ENV=production browserify -g envify src/main.js | uglifyjs -c warnings=false -m > dist/build.js",
    "postinstall": "npm install express",
    "start": "npm-run-all --parallel watchify serve"
  },
  "dependencies": {
    "express": "^4.16.2",
    "vue": "^2.0.1",
    "babel-core": "^6.0.0",
    "babel-preset-es2015": "^6.0.0",
    "babelify": "^7.2.0",
    "browserify": "^13.0.1",
    "browserify-hmr": "^0.3.1",
    "cross-env": "^1.0.6",
    "envify": "^3.4.1",
    "http-server": "^0.9.0",
    "npm-run-all": "^2.1.2",
    "uglify-js": "^2.5.0",
    "vueify": "^9.1.0",
    "watchify": "^3.4.0"
  },
  "browserify": {
    "transform": [
      "vueify",
      "babelify"
    ]
  },
  "browser": {
    "vue": "vue/dist/vue.common.js"
  }
}

I left as dependencies and not devDependencies for Heroku to be able to use them, and changed the properties start and serve .

    
03.01.2018 / 14:08