简体   繁体   English

早午餐编译的JS无法运行

[英]JS compiled by Brunch does not run

I wanted to try out Brunch and am having some trouble getting my compiled JS files to execute in the browser. 我想尝试早午餐,让我的已编译JS文件在浏览器中执行时遇到一些麻烦。

The file gets compiled and loaded by the page into the browser. 该文件由页面编译并加载到浏览器中。 If I stick an alert or a console log in the source files and do a build, then nothing happens when I load the page. 如果我在源文件中粘贴警报或控制台日志并进行构建,那么在加载页面时什么也不会发生。

If I edit the file manually and put a console log or an alert into it then it works just fine. 如果我手动编辑文件并将控制台日志或警报放入文件中,则它可以正常工作。

Does anyone have any ideas? 有人有什么想法吗? I feel like I'm probably just missing something silly. 我觉得我可能只是想念一些愚蠢的东西。

This is what I have in my brunch config file 这是我的早午餐配置文件中的内容

exports.paths = {
  watched: ['client'],
}

exports.files = {
  javascripts: { joinTo: 'javascripts/app.js' },
  stylesheets: { joinTo: 'stylesheets/app.css' }
}

exports.plugins = {
  sass: {
    options: {
      includePaths: ['node_modules/foundation-sites/scss']
    }
  }
}

I have the following brunch plugins in my package.json 我的package.json中有以下早午餐插件

"babel-brunch": "^6.1.1",
"clean-css-brunch": "^2.10.0",
"sass-brunch": "^2.10.4",
"uglify-js-brunch": "^2.10.0"

are you requiring the build in your html? 您是否需要在html中进行构建?

see below: 见下文:

<script src="app.js"></script>
<script>require('initialize')</script>

by default brunch.io registers everything into commonjs modules. 默认情况下,brunch.io将所有内容注册到commonjs模块中。 It then registers a "initialize" module to bootstrap the app and start everything. 然后,它注册一个“初始化”模块以引导应用程序并启动所有程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM