反复创建新的min.js文件

时间:2019-08-04 02:52:41

标签: javascript php visual-studio min.js

我有一个文件“ script.js”,现在反复制作新的“ min.js”,例如 script.min.min.js ,然后是 script.min.min.js ,然后 script.min.min.min.js

我猜想这与我在“ functions.php”中将脚本排队的方式有关,但是对此一无所知

删除除原始文件外的所有文件

wp_enqueue_script( 'theme-script', get_template_directory_uri() . '/js/script.js', array(), '20190731', true );
gulp.task('lint', () => 
  gulp.src(['./js/*.js'])
  .pipe(prettyError())
  .pipe(eslint())
  .pipe(eslint.format())
  .pipe(eslint.failAfterError())); 

gulp.task( 'scripts', gulp.series('lint', () => 
  gulp.src('./js/*.js')
  .pipe(terser())
  .pipe(rename({ extname: '.min.js' }) 
  .pipe(gulp.dest('./js')))); 

我只需要script.js,如果需要的话可能还需要script.min.js

1 个答案:

答案 0 :(得分:0)

问题是您正在缩小脚本并将它们放在它们来自的相同目录中。因此,下次运行压缩文件时,将重新压缩压缩后的脚本,并在文件名中添加一个额外的AllowAmbiguousTypes

通常,您要将脚本移动到某种分发文件夹中。可能看起来像这样:

{-# LANGUAGE EmptyCase #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE AllowAmbiguousTypes #-}

import GHC.Generics

class GetIndex' f where
  getIndex' :: f p -> Int
  size :: Int

instance GetIndex' f => GetIndex' (D1 t f) where
  getIndex' (M1 x) = getIndex' x
  size = size @f

-- We've reached a constructor. It doesn't matter what it
-- looks like; the results will be the same regardless.
instance GetIndex' (C1 t f) where
  getIndex' _ = 0
  size = 1

instance GetIndex' V1 where
  getIndex' v = case v of
  size = 0

instance (GetIndex' f, GetIndex' g) => GetIndex' (f :+: g) where
  getIndex' (L1 x) = getIndex' x
  getIndex' (R1 x) = size @f + getIndex' x
  size = size @f + size @g

getIndex :: (Generic a, GetIndex' (Rep a)) => a -> Int
getIndex = getIndex' . from

此外,请确保从版本控制(通常为.min)中排除gulp.task( 'scripts', gulp.series('lint', () => gulp.src('./js/*.js') .pipe(terser()) .pipe(rename({ extname: '.min.js' }) .pipe(gulp.dest('./dist/js')))); 文件夹。