在我的index.html文件中,我添加了以下内容:
<!-- bower:js -->
<!-- endbower -->
Run Code Online (Sandbox Code Playgroud)
为了让install-bowergrunt 任务放置我所有的 Bower 依赖项。在我的 中Gruntfile.js,我有以下任务:
'bower-install': {
dist: {
html: 'cwf/index.html'
}
}
Run Code Online (Sandbox Code Playgroud)
最后,在我的 中index.html,我得到类似的东西:
<!-- bower:js -->
<script src="bower_components/jquery/jquery.js"></script>
<script src="bower_components/angular/angular.js"></script>
...
<!-- endbower -->
Run Code Online (Sandbox Code Playgroud)
但是,我想将任务配置为../在 之前添加bower_components,以便得到:
<!-- bower:js -->
<script src="../bower_components/jquery/jquery.js"></script>
<script src="../bower_components/angular/angular.js"></script>
...
<!-- endbower -->
Run Code Online (Sandbox Code Playgroud)
我如何为此目的配置任务?
我一直在寻找一些自动生成角度应用程序的方法。我尝试在 YEOMAN 上使用角度生成器,但我不喜欢提供的应用程序结构。
我发现了这个其他生成器angular-feature ( https://github.com/codigo-pl/generator-angular-feature ),它似乎解决了我的问题。但到目前为止,我无法让它发挥作用。每次当我尝试生成应用程序(在功能结构上)时,都会返回一个错误:
命令:grunt build(即使我尝试 grunt server 返回我相同)
C:\Users\xxxxxx\WorkFolders\temp\testGenerator>grunt build 正在加载“cdnify.js”任务...错误
错误:无法解析 C:\Users\xxxxxx\WorkFolders\temp\testGenerator .bowerrc:意外令牌 v 警告:找不到任务“cdnify”。使用 --force 继续。
由于警告而中止。
更新:
在文件 .bowerrc 中:
{
"directory": "app\vendor/bower_components"
}
Run Code Online (Sandbox Code Playgroud)
运行生成器后我的文件夹:
testGenerator
--app
----src
------common
--node_modules
Run Code Online (Sandbox Code Playgroud)
我的 APP 文件夹中的任何地方都没有bower_components文件夹。
有没有人已经使用过这个 YEOMAN 生成器并且遇到了同样的问题?是否有另一个 YEOMAN 生成器由这样的功能构成?
我正在尝试使用beanstalk部署我的应用程序.我开始我的本地环境grunt dev.错误显示无法找到grunt.
登录到服务器后eb ssh,我看到npm也没有安装.
我正在寻找解决此问题的后续步骤.
.ebextensions/01_grunt.config
option_settings:
- namespace: aws:elasticbeanstalk:container:nodejs
option_name: NodeCommand
value: "grunt dev"
Run Code Online (Sandbox Code Playgroud)
eb日志
...
-------------------------------------
/var/log/nodejs/nodejs.log
-------------------------------------
Wed, 04 Mar 2015 19:07:54 GMT express deprecated res.sendfile: Use res.sendFile instead at server.js:6:7
static file request : [object Object]
Wed, 04 Mar 2015 19:07:54 GMT express deprecated res.sendfile: Use res.sendFile instead at server.js:12:7
Error: ENOENT, stat '/var/app/current/libs/bootstrap-css/css/bootstrap.css'
static file request : [object Object]
static file request : [object Object]
Error: ENOENT, stat '/var/app/current/dist/libs.js' …Run Code Online (Sandbox Code Playgroud) 我正在尝试将我的Google Closure Library使用的网络应用程序转换为Electron.我曾经grunt-electron打包过应用程序,但它似乎并没有改变Test.app的默认应用程序.在Test.app/Contents/Contents/app/中存在我的应用程序,但它不加载我的应用程序,但确实加载默认应用程序.
我的档案层次:
我的笨蛋任务:
electron: {
osxBuild: {
options: {
name: 'Test App',
dir: 'www',
out: 'build',
version: '0.25.3',
platform: 'darwin',
arch: 'x64'
}
}
}
Run Code Online (Sandbox Code Playgroud) 我正在使用Yeoman webapp生成器(https://github.com/yeoman/generator-webapp),我已经添加了Bower包GMAPS(https://github.com/hpneo/gmaps).将Gmaps添加到我的项目后,我在项目的顶部添加了Google Api链接
<!-- build:css(.tmp) styles/main.css -->
<script src="http://maps.google.com/maps/api/js?sensor=true"></script>
<link href='http://fonts.googleapis.com/css?family=PT+Sans' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="styles/main.css">
<!-- endbuild -->
Run Code Online (Sandbox Code Playgroud)
问题是,当我使用Grunt Serve命令时,我看到我的Gmaps出现在我的本地主机上运行的网站上.如果我Grunt构建我的项目它总是给我一个错误,在我的main.js文件中它找不到变量Gmaps(用于触发Gmaps插件).
所以我的问题是:如何将API添加到使用Grunt构建的项目中?
我第一次玩弄ES6模块,尝试与Webpack进行基本的捆绑.我想使用Babel 6(目前最新和最好的)在Webpack加载器中进行转换.我已经读过这个以及这个和这个.
package.json包括:
"devDependencies": {
"babel": "~6.0.12",
"babel-core": "~6.0.12",
"babel-loader": "~6.0.0",
"babel-preset-es2015": "^6.0.14",
"grunt": "~0.4.5",
"grunt-webpack": "^1.0.11",
"webpack": "^1.12.2",
"webpack-dev-server": "^1.12.1"
},
Run Code Online (Sandbox Code Playgroud)
文件结构:
myproject
??? js
? ??? es6
? ? ??? app.js
? ? ??? lib
? ? ? ??? lib1.js
? ? ? ??? lib2.js
? ? ??? modules
? ? ??? _myModule.js
??? node_modules
??? index.html
??? gruntfile.js
Run Code Online (Sandbox Code Playgroud)
gruntfile.js
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
webpack: {
options: {
entry: …Run Code Online (Sandbox Code Playgroud) 我是 Grunt 及其所有插件的新手,但我想学习和设置一些很棒的前端工具。话虽如此,我一直在通过Github关注Grunt 文档以及 Grunt 和 Babel 的一些类似问题,但我似乎不断收到以下回溯:
Running "babel:dist" (babel) task
Warning: Unable to write "dist" file (Error code: EISDIR). Use --force to continue.
Aborted due to warnings.
Run Code Online (Sandbox Code Playgroud)
任何对这个新手更清晰的解释将不胜感激。我是 JS 编程和设置 DevOps 的新手,因此鼓励提供一些有用的提示和最佳实践。
设置:
js_practice/ (根项目)
|----package.json
所有发行版和包
|---node_modules/
服务器端(节点)支持
|---es6/
| ------ test.js
|---dist/
客户端(浏览器)支持
|----public/
|---es6/ (位于 public 文件夹内)
| ----- test2.js
|---dist/ (这是在公共文件夹中)
这是我当前的代码:
Grunt 文件.js
module.exports = function(grunt) {
// All of your Grunt code must be specified inside this function!
// …Run Code Online (Sandbox Code Playgroud) 标题说明了一切。我的 postcss 任务如下:
postcss: {
options: {
processors: [
require('autoprefixer')({browsers: ['last 2 versions']}),
require('cssnext')(),
require('precss')()
]
},
dist: {
src: '*.css',
dest: 'style.css',
}
},
Run Code Online (Sandbox Code Playgroud)
目前我有另一个名为 style-human 的 css 文件,我也想添加前缀。但是,该任务仅在 style.css 文件(缩小版本)前加上前缀。
我有一个我正在开发的webapp,它使用HTML + Javascript(Angular 1.5.0)+ CSS的前端.当我在本地主机上运行时,网站运行良好.我有一个/index.html文件.这个文件导入我的javascript代码,如下所示:<script src="/app/app.js"></script>
但现在我刚刚使用Grunt实现了自动linting,uglifying等.Grunt非常好地将我的单个Javascript文件(/app/app.cs)转换为minnified one(/dist/js/app.min.js).我改变了我/index.html对包括minnified的Javascript来代替:<script src="/dist/js/app.min.js"></script>.但现在应用程序停止工作.在浏览器的开发控制台中,我看到以下错误:
angular.js:68 Uncaught Error: [$injector:modulerr] Failed to instantiate module myApp due to:
Error: [$injector:unpr] Unknown provider: a
http://errors.angularjs.org/1.5.0/$injector/unpr?p0=a
at http://127.0.0.1:8080/bower_components/angular/angular.js:68:12
at http://127.0.0.1:8080/bower_components/angular/angular.js:4397:19
at getService (http://127.0.0.1:8080/bower_components/angular/angular.js:4550:39)
at injectionArgs (http://127.0.0.1:8080/bower_components/angular/angular.js:4574:58)
at Object.invoke (http://127.0.0.1:8080/bower_components/angular/angular.js:4596:18)
at runInvokeQueue (http://127.0.0.1:8080/bower_components/angular/angular.js:4497:35)
at http://127.0.0.1:8080/bower_components/angular/angular.js:4506:11
at forEach (http://127.0.0.1:8080/bower_components/angular/angular.js:321:20)
at loadModules (http://127.0.0.1:8080/bower_components/angular/angular.js:4487:5)
at createInjector (http://127.0.0.1:8080/bower_components/angular/angular.js:4409:19)
http://errors.angularjs.org/1.5.0/$injector/modulerr?p0=raptorApp&p1=Error%…F%2F127.0.0.1%3A8080%2Fbower_components%2Fangular%2Fangular.js%3A4409%3A19)
Run Code Online (Sandbox Code Playgroud)
为什么正常的Javascript文件可以正常工作,但Grunt缩小的文件不会?我该如何解决?
我一直试图在我的项目上安装grunt但没有运气.
这是运行npm install时出现的错误
npm WARN package.json XXX@1.0.0 No license field.
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! node v0.12.7
npm ERR! npm v2.11.3
npm ERR! code EPEERINVALID
npm ERR! peerinvalid The package grunt does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer grunt-contrib-copy@0.8.2 wants grunt@>=0.4.0
npm ERR! peerinvalid Peer grunt-contrib-sass@0.9.2 wants grunt@>=0.4.0
npm ERR! peerinvalid Peer grunt-contrib-watch@0.6.1 wants grunt@~0.4.0
npm ERR! peerinvalid Peer grunt-mustache-render@1.9.0 wants grunt@^0.4.5
Run Code Online (Sandbox Code Playgroud)
继承人'我的包json看起来像什么
{
"name": "XXX",
"version": …Run Code Online (Sandbox Code Playgroud) 如何在Grunt文件中添加一行/ s以确保它找到部分视图?
我的grunt.js文件是你用Yeoman搭建AngularJS应用程序,没有插件或JQuery,只是Angular时提供的vanilla.
gruntjs ×11
javascript ×6
angularjs ×3
bower ×2
node.js ×2
yeoman ×2
babeljs ×1
electron ×1
grunt-babel ×1
npm ×1
npm-install ×1
postcss ×1
webpack ×1