我一直在使用Vue.js的大多数香草Webpack配置。我一直在试图找出导致它破裂的原因,但是我的指纹似乎再也无法正常工作了。每次我更新其中一个组件时,都会如您期望的那样重新加载一个包。
问题在于,在生产环境中,浏览器似乎不再对此有所了解。因此它将尝试使用旧包,而不是找到它并使我的应用程序崩溃。只有清除缓存以使其再次下载所有包,它才会获得带有新指纹的包。
const webpack = require('webpack')
const { environment } = require('@rails/webpacker')
const vue = require('./loaders/vue')
const { VueLoaderPlugin } = require('vue-loader')
const additionalConfig = {
plugins: [
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
filename: 'vendor.js',
minChunks: 3,
}),
],
module: {
rules: [
{
test: /\.pug$/,
loader: 'pug-plain-loader'
}
]
},
output: {
sourceMapFilename: '[name].js.map',
},
devtool: 'source-map',
}
environment.config.merge(additionalConfig);
environment.loaders.append('vue', vue)
module.exports = environment
默认情况下,Rails似乎会指纹识别所有内容,因此output
中没有手动设置。但是我也尝试过,没有明显的区别。
import 'element-ui/lib/theme-chalk/index.css';
import 'element-ui/lib/theme-chalk/display.css';
import 'flexboxgrid/css/flexboxgrid.css';
import 'ionicons/dist/scss/ionicons.scss';
import Vue from 'vue/dist/vue.esm';
import ElementUI from 'element-ui';
import locale from 'element-ui/lib/locale/lang/en';
import UserOnboarding from '../components/sessions/TheOnboarding.vue';
import TopNavigation from '../components/navigation/TheTopNavigation.vue';
import { store } from '../store';
Vue.use(ElementUI, { locale });
const app = new Vue({
el: '#app',
store,
mounted() {
var selector = document.querySelector("#app");
if (selector) {
store.commit('base_states/authenticate',
JSON.parse(selector.dataset.signedIn)
);
}
},
components: { UserOnboarding, TopNavigation },
});
ActionController::RoutingError: No route matches [GET] "/packs/landing_page-dbab12fce266dd6c1529.js"