JS compiled by Brunch does not run

倾然丶 夕夏残阳落幕 提交于 2019-12-11 05:00:07

问题


I wanted to try out Brunch and am having some trouble getting my compiled JS files to execute in the browser.

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

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

回答1:


are you requiring the build in your html?

see below:

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

by default brunch.io registers everything into commonjs modules. It then registers a "initialize" module to bootstrap the app and start everything.



来源:https://stackoverflow.com/questions/42610591/js-compiled-by-brunch-does-not-run

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!