postinstall webpack不能在Heroku上运行

时间:2016-02-13 02:08:48

标签: node.js heroku webpack post-install

我正在使用Heroku来托管我的应用程序和webpack来构建它。

基本上,我正在尝试部署我的应用,但它根本不起作用。

似乎没有发生postinstall,因为当我加载页面时,它缺少文件bundle.js(通过webpack构建)。

这是我的package.json脚本:

"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"
}

当我将项目推送到heroku时,在此过程中没有显示错误。我可以在控制台中看到它正在运行我的postinstall:

  

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

这是我的整个webpack.prod.config.js文件:

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 个答案:

答案 0 :(得分:0)

--progress标志会导致heroku不喜欢的大量打印语句和日志消息,并导致进程崩溃。尝试在没有--progress标志的情况下运行