【发布时间】:2018-06-01 15:17:59
【问题描述】:
我正在通过 CLI 使用 Ionic 3。
在使用离子服务时,我想添加自定义脚本“auth”:
提示输入用户名和密码
使用 api 创建 cookie,并在调用每个 API 时使用此 cookie。
我的Gruntfile.js
我在 grunt 中创建了自定义服务器任务:
提示用户登录
创建 cookie 并将此 cookie 应用于每个请求。
能够使用来自
package.json的 ionic 管理运行。
grunt.registerTask('server', ['checkAuthToken', 'applyAuthToken', 'configureRewriteRules', 'configureProxies']);
"scripts": { "auth": "grunt server", }
现在我想知道如何在 ionic serve 之前导入此身份验证任务,以便我的代理和身份验证工作。
我的package.json中的脚本
我在package.json 中尝试使用下面的 npm-script。它会提示输入用户名、密码并创建 cookie,但是我的代理不起作用,因为我的 grunt 任务是在 ionic watch 之后和 ionic build 之前运行的。
...
"ionic:serve": "ionic-app-scripts serve && grunt server",
"ionic:serve": "grunt server && ionic-app-scripts serve"
...
【问题讨论】:
标签: ionic-framework gruntjs ionic3