6

I'm using Heroku to host my app and webpack to build it.

Basically, I'm trying to deploy my app, but it doesn't work at all.

The postinstall doesn't seem to occur since when I load the page it's missing the file bundle.js (which is built via webpack).

Here is my package.json scripts:

"main": "server.js",
"scripts": {
    "dev": "webpack-dev-server --devtool eval --content-base build/ --colors --hot",
    "start": "node server.js",
    "postinstall": "webpack -p --config webpack.prod.config.js --progress"
}

When I push my project to heroku, there is no error displayed during the process. I can see in the console that it's running my postinstall:

remote: > pistou@1.0.0 postinstall /tmp/build_80dea0f9774d7a9a5f8f33ee9c913bca remote: > webpack -p --config webpack.prod.config.js --progress

Here is my whole webpack.prod.config.js file:

var path = require('path');
var webpack = require('webpack');
var node_dir = path.resolve(__dirname, 'node_modules');

module.exports = {
    entry: [
        'unveil',
        path.resolve(__dirname, 'app/main.js')
    ],
    output: {
        path: path.resolve(__dirname, 'dist'),
        filename: 'bundle.js',
        publicPath: '/'
    },
    module: {
        loaders: [
            {
                test: /\.jsx?$/,
                include: path.join(__dirname, 'app'),
                loader: 'babel'
            },
            {
                test: /\.scss$/,
                include: path.join(__dirname, 'app/styles'),
                loader: 'style!css!sass'
            },
            {
                test: /\.(png|jpg)$/,
                loader: "file"
            },
            { test: /\.woff(\?v=\d+\.\d+\.\d+)?$/,  loader: "url?limit=10000&mimetype=application/font-woff" },
            { test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&mimetype=application/font-woff" },
            { test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,   loader: "url?limit=10000&mimetype=application/octet-stream" },
            { test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,   loader: "url?limit=10000&mimetype=image/svg+xml" },
            { test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,   loader: "file" }
        ]
    },
    plugins: [
        new webpack.NoErrorsPlugin(),
        new webpack.ProvidePlugin({
            $: "jquery",
            jQuery: "jquery",
            "window.jQuery": "jquery",
        }),
        new webpack.ContextReplacementPlugin(/moment[\/\\]locale$/, /(fr|en)$/),
        new webpack.DefinePlugin({
            "process.env": {
                "NODE_ENV": JSON.stringify("production")
            }
        }),
        new webpack.optimize.UglifyJsPlugin({
            minimize: true,
            compress: {
                warnings: false
            }
        }),
    ],
    resolve: {
        alias: {
            "unveil": "./app/statics/jquery.unveil.js",
        }
    },
};
pistou
  • 2,799
  • 5
  • 33
  • 60
  • 12
    Is `webpack` correctly installed ? If it's in your `devDependencies`, you need to `heroku config:set NPM_CONFIG_PRODUCTION=false`. You should remove the `webpack.NoErrorsPlugin` in production, so that your build doesn't fail silently and you could see the errors you might be missing – topheman Feb 13 '16 at 02:19
  • @topheman You were right there was a silent error running. Thanks ! – pistou Feb 13 '16 at 02:36
  • 1
    thanks! setting that config made my build pass. this should be in the docs – paul May 07 '16 at 13:22
  • 3
    Sorry to bother on an old post, but @topheman it'd be great if you posted an answer to the question, it helped me a lot :^) – Andrew Li Nov 22 '16 at 04:56

1 Answers1

0

The --progress flag leads to a high number of print statements and log messages which heroku doesn't like and makes the process crash. Try to run without the --progress flag

Reinier
  • 195
  • 2
  • 14