小编Leo*_*rra的帖子

Gulp:任务从未定义:任务

我试图弄清楚如何使用 Gulp,但我不断收到一个错误,我不知道如何解决

当我使用它们的函数编译我的 SCSS 和 JS 文件时,它会正常编译但是当我尝试设置javascript gulp.task('watch')javascript gulp.task('default')出现错误消息时

这是我的 gulpfile.js

const gulp = require('gulp');
const babel = require('gulp-babel');
const cssnano = require('gulp-cssnano');
const sass = require('gulp-sass');
const concat = require('gulp-concat');
const uglify = require('gulp-uglify');

const myFiles = [
    './app/js/vendors/*.js',
    './app/js/functions.js',
    './app/js/view.js'
]


gulp.task('sass', function () {
    return gulp.src('./app/style.scss')
        .pipe(sass())
        .pipe(cssnano())
        .pipe(gulp.dest('./dist/css'))
})


gulp.task('js', function () {
    return gulp.src(myFiles)
        .pipe(babel({
            presets: ['@babel/env']
        }))
        .pipe(concat('all.js'))
        .pipe(uglify())
        .pipe(gulp.dest('dist'));
})


gulp.task('watch', function () {
    gulp.watch('./app/*.scss', ['sass']);
    gulp.watch('./app/js/**/*.js', ['js']);
}); …
Run Code Online (Sandbox Code Playgroud)

javascript gulp

4
推荐指数
1
解决办法
1万
查看次数

Nodemon 和 Jest,仅在异步运行 Babel 时支持

我正在尝试运行 Jest,但此错误始终阻止我运行任何测试:

Error while loading config - 
You appear to be using a native ECMAScript module configuration file, which is only supported when running Babel asynchronously.

at loadCjsOrMjsDefault (node_modules/@babel/core/lib/config/files/module-types.js:59:13)
          at loadCjsOrMjsDefault.next (<anonymous>)
      at readConfigJS (node_modules/@babel/core/lib/config/files/configuration.js:174:47)
          at readConfigJS.next (<anonymous>)
      at Function.<anonymous> (node_modules/@babel/core/lib/gensync-utils/async.js:16:3)
      at evaluateSync (node_modules/gensync/index.js:251:28)
      at Function.sync (node_modules/gensync/index.js:89:14)
      at sync (node_modules/@babel/core/lib/gensync-utils/async.js:56:25)
      at sync (node_modules/gensync/index.js:182:19)
Run Code Online (Sandbox Code Playgroud)

我正在使用nodemonsucrase运行我的服务器(如果相关的话)。

我的巴贝尔配置

Error while loading config - 
You appear to be using a native ECMAScript module configuration file, which is only supported when …
Run Code Online (Sandbox Code Playgroud)

node.js nodemon jestjs

4
推荐指数
1
解决办法
3646
查看次数

生产和暂存构建不同

我的应用程序有 3 个环境,这会更改 API 基本 url:

\n

\xe2\x80\xa2 生产

\n

\xe2\x80\xa2 暂存

\n

\xe2\x80\xa2 本地

\n

当构建我的生产应用程序时,我使用它$ vue-cli-service build以应有的方式构建一切,完美!

\n

当我使用分段构建时$ vue-cli-service build --mode staging,这给我带来了一些问题:

\n

\xe2\x80\xa2 我的文件具有与生产环境不同的压缩风格;

\n

\xe2\x80\xa2 我的文件经过 \xe2\x80\x99t 哈希处理,包含 [名称].[哈希值].[扩展名]

\n

\xe2\x80\xa2 我的 service-worker 是由根目录下的 registerServiceWorker 生成的 \xe2\x80\x99t。

\n

如何将我的暂存版本设置为与我在生产中使用的完全相同的版本?

\n

在此输入图像描述

\n

我的网页包配置

\n
const path = require("path");\nconst webpack = require("webpack");\nconst WebpackAssetsManifest = require(\'webpack-assets-manifest\');\n\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.scss$/,\n        use: ["vue-style-loader", "css-loader", "sass-loader"]\n      },\n      {\n        test: /\\.csv$/,\n        loader: …
Run Code Online (Sandbox Code Playgroud)

webpack vue.js

3
推荐指数
1
解决办法
1444
查看次数

Nodejs客户端发送请求的安全问题

我正在创建一个浏览器游戏,我知道浏览器并不真正安全,但我想知道是否有任何解决我的问题的方法。

玩家杀死怪物,平台将 ID 发送到我的后端,如下所示:

Axios({
   url: this.server + "reward",
   headers: { token: "foo123", charToken: "bar123" },
   method: "POST",
   data: {
      id: 10001, // Monster ID
      value: 10 // How many monsters were killed
   },
});
Run Code Online (Sandbox Code Playgroud)

问题是,我认为没有办法阻止用户向服务器发送随机请求,说他实际上在一秒钟内完成了这个关卡 300 次,并获得了 300 倍的奖励物品/经验。

我想过在发送这个reward请求之前请求一个令牌,但这只会让事情变得更困难,而且并不能真正解决任何问题。

javascript rest ddos rate-limiting node.js

0
推荐指数
1
解决办法
236
查看次数

标签 统计

javascript ×2

node.js ×2

ddos ×1

gulp ×1

jestjs ×1

nodemon ×1

rate-limiting ×1

rest ×1

vue.js ×1

webpack ×1