我正在使用 webpacker gem将应用程序从rails 3.2升级到rails 4.2一切正常 localhost 我编译了我的资产并运行
RAILS_ENV =生产轨道s
但是当我推送到 heroku 时我有错误它会编译所有资产甚至包但是在js中生成错误,我在应用程序的许多部分使用角度并且错误与依赖注入有关
答案 0 :(得分:0)
这里的主要问题是我必须给uglifier注射的unglifier gem
#config.assets.js_compressor = :uglifier
下一部分是生产中 webpack 的配置,如下所示:
const webpack = require('webpack')
const { basename, dirname, join, relative, resolve } = require('path')
const merge = require('webpack-merge')
const CompressionPlugin = require('compression-webpack-plugin')
const sharedConfig = require('./shared.js')
const { env, settings, output, loadersDir } = require('./configuration.js')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const ManifestPlugin = require('webpack-manifest-plugin')
module.exports = merge(sharedConfig, {
output: { filename: '[name]-[chunkhash].js' },
devtool: false,//'source-map',
stats: 'normal',
plugins: [
new webpack.EnvironmentPlugin(JSON.parse(JSON.stringify(env))),
new ExtractTextPlugin({
filename: '[name]-[hash].css',
allChunks: true
}),
new ManifestPlugin({
publicPath: output.publicPath,
writeToFileEmit: true
})
],
resolve: {
extensions: settings.extensions,
modules: [
resolve(settings.source_path),
'node_modules'
],
alias: {
'vue$': 'vue/dist/vue.esm.js' // 'vue/dist/vue.common.js' for webpack 1
}
},
resolveLoader: {
modules: ['node_modules']
}
})
现在我可以部署并且资产正在运行。