postinstall webpack not working on Heroku

5k Views Asked by At

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: > [email protected] 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",
        }
    },
};
1

There are 1 best solutions below

0
On

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