简体   繁体   English

javascript:在浏览器中从Atom运行/执行

[英]javascript: Run / Execute from Atom in Browser

While trying to learn javascript, I stumbled upon Typescript and decided to rather learn that. 在尝试学习javascript时,我偶然发现了Typescript,并决定学习。 I installed Atom and the atom-typescript module and coded a typescript class, which compiles to a .js file. 我安装了Atom和atom-typescript模块,并编码了一个打字稿类,该类编译为.js文件。 I created an index.html page with the .js in a script tag. 我在脚本标签中创建了带有.js的index.html页面。

As far as I understand, in order to test the js code, I have to start a webserver and load index.html. 据我了解,为了测试js代码,我必须启动一个Web服务器并加载index.html。

What would be a convenient way to do that? 什么是便捷的方法? At least, I would like to manually run the script from Atom with a keyboard shortcut. 至少,我想使用键盘快捷键从Atom手动运行脚本。 Ideally, I would like the browser to refresh every time the typescript file changes in Atom. 理想情况下,我希望浏览器在Atom中每次打字稿文件更改时刷新一次。 No google result I could find explains how to do that, is that a difficult thing to do? 我找不到Google的搜索结果来说明如何执行此操作,这很难吗?

What would be a convenient way to do that? 什么是便捷的方法?

Use browserify to reload your webapp everytime the JS changes. 每次JS更改时,请使用browserify重新加载您的Web应用程序。 Also use nodemon to restart your webserver each time the backend JS changes. 每次后端JS更改时,也请使用nodemon重新启动Web服务器。

Example: 例:

Checkout http://typescriptbuilder.com/ 结帐http://typescriptbuilder.com/

Nodemon config: https://github.com/TypeScriptBuilder/tsb/blob/master/nodemon.json Nodemon配置: https : //github.com/TypeScriptBuilder/tsb/blob/master/nodemon.json

Wepack config: https://github.com/TypeScriptBuilder/tsb/blob/master/src/webpack.config.ts Wepack配置: https : //github.com/TypeScriptBuilder/tsb/blob/master/src/webpack.config.ts

Webpack config during devtime: https://github.com/TypeScriptBuilder/tsb/blob/8a7d48d71a8327d48822fa15eb52b9adb1953223/src/server/devtime.ts#L15-L82 开发期间的Webpack配置: https : //github.com/TypeScriptBuilder/tsb/blob/8a7d48d71a8327d48822fa15eb52b9adb1953223/src/server/devtime.ts#L15-L82

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

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