简体   繁体   English

将JavaScript文件添加到Yeoman Webapp生成的网站

[英]Adding javascript files to Yeoman webapp generated website

I am playing with the yoman trying to build a web site using the webapp generator. 我正在与yoman一起玩,尝试使用webapp生成器构建网站。

If Managed to create a web site that works under grunt server, when I change a js file grunt notices the change change and does a live load and everything works as you would expect. 如果设法创建一个在grunt服务器下工作的网站,当我更改js文件时,grunt会注意到更改并进行实时加载,一切都会按您的预期进行。

When I try a plan grunt, it attempts to run the dist task, it manages to include my html files, but skips any of the javascript or script files I created in the script and styles diretores. 当我尝试计划计划时,它尝试运行dist任务,它设法包含了我的html文件,但是跳过了我在脚本和样式目录中创建的任何javascript或脚本文件。 I assume its the case I have to tell grunt to includes these files 我假设是这种情况,我必须告诉grunt包括这些文件

Files such as main.js seem to make it through, but there are no references to main.js in the Gruntfile, so I not sure which part of Gruntfile.js to change. 诸如main.js之类的文件似乎可以通过,但是Gruntfile中没有对main.js的引用,因此我不确定Gruntfile.js的哪一部分要更改。

Doing a yo doctor reports [Yeoman Doctor] Everything looks all right! 做溜溜医生报告[Yeoman Doctor]一切看起来都不错!

Q. How to do I tell grunt to include and user created files. 问:如何告诉grunt包含和用户创建的文件。

Q. I noticed that all my image files where renamed, fair enough how do I refer to a file that I known is going to be renamed in a javascript file 问:我注意到我的所有图像文件都已重命名,这很公平,我如何引用一个已知文件,该文件将在javascript文件中重命名。

Q. Does anybody known a good web resource for yoman where these quesion might have already been answered? 问:是否有人为yoman知道了一个很好的Web资源,这些问题可能已经得到回答?

Be careful on this glob pattern scripts/{,*}/*.js . 请注意此glob模式scripts/{,*}/*.js This takes only the js files that are inside scripts or immediate child folders. 这仅需要脚本或直接子文件夹中的js文件。

Make sure to change it to scripts/**/*.js to include all js files in all subfolders. 确保将其更改为scripts/**/*.js以在所有子文件夹中包含所有js文件。

Also get an idea on tags build: css , build: js in your index.html, wiredep plugin used by Yeoman in gruntfile to understand what files will be injected into dist folder. 还可以在index.html中wiredep标签build: cssbuild: js的想法, wiredep是Yeoman在gruntfile中使用的wiredep插件,用于了解将哪些文件注入dist文件夹。

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

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