我正在使用 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 安装后 /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",
}
},
};