清单未加载webpacker application.js

问题描述 投票:0回答:1

升级到Ruby on Rails 5后,我试图切换到webpacker。但是尝试使用= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload'时出现错误。

错误是

Webpacker can't find application in /vagrant/public/packs/manifest.json. Possible causes:
1. You want to set webpacker.yml value of compile to true for your environment
   unless you are using the `webpack -w` or the webpack-dev-server.
2. webpack has not yet re-run to reflect updates.
3. You have misconfigured Webpacker's config/webpacker.yml file.
4. Your webpack configuration is not creating a manifest.
Your manifest contains:
{}

app / assets / config / manifest.js

//= link_tree ../images
//= link_directory ../../javascript/packs .js

app / javascripts / packs / application.js

const images = require.context('../../assets/images', true)
const imagePath = (name) => images(name, true)

console.log('Hello World from Webpacker')

// jquery
import $ from 'jquery';
import 'jquery-ui-dist/jquery-ui';
import 'bootstrap/dist/js/bootstrap';
import 'select2';
import 'select2/dist/css/select2.css';
import 'u2f-api/dist/lib/u2f-api';
import 'jquery.prettyphoto'

global.$ = $
global.jQuery = $

app / views / layouts / application.html.haml

= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload'
= stylesheet_pack_tag 'bootstrap'

日志错误

20:13:31 web.1  | [Webpacker] Compiling...
20:13:31 web.1  | [Webpacker] Compilation failed:
20:13:31 web.1  | /vagrant/node_modules/webpack-cli/bin/cli.js:93
20:13:31 web.1  |                               throw err;
20:13:31 web.1  |                               ^
20:13:31 web.1  | 
20:13:31 web.1  | ReferenceError: webpack is not defined
20:13:31 web.1  |     at Object.<anonymous> (/vagrant/config/webpack/environment.js:8:40)
20:13:31 web.1  |     at Module._compile (/vagrant/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
20:13:31 web.1  |     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1171:10)
javascript ruby-on-rails webpack webpack-dev-server
1个回答
0
投票

您尝试在何处使用javascript_pack_tag'application','data-turbolinks-track':'reload'?您可以显示文件吗?

© www.soinside.com 2019 - 2024. All rights reserved.