У меня проблема с gulp-clean- css в моем gulpfile.babel. js file
package. json
{
"name": "project",
"version": "1.0.0",
"scripts": {
"test": ""
},
"devDependencies": {
"@babel/core": "^7.8.3",
"@babel/preset-env": "^7.8.3",
"@babel/register": "^7.8.3",
"autoprefixer": "^9.7.3",
"babel-loader": "^8.0.6",
"browser-sync": "^2.26.7",
"del": "^5.1.0",
"dotenv": "^6.0.0",
"gulp": "^4.0.0",
"gulp-clean-css": "^4.2.0",
"gulp-if": "^3.0.0",
"gulp-imagemin": "^6.2.0",
"gulp-postcss": "^8.0.0",
"gulp-replace": "^1.0.0",
"gulp-sass": "^4.0.2",
"gulp-sourcemaps": "^2.6.5",
"gulp-zip": "^5.0.1",
"vinyl-named": "^1.1.0",
"webpack-stream": "^5.2.1",
"yargs": "^13.3.0"
}
}
babelr c
{
"presets": [ "@babel/preset-env" ]
}
gulfile.babel. js
import { themeLocation } from './settings';
import gulp from 'gulp';
import yargs from 'yargs';
//styles
import sass from 'gulp-sass';
import cleanCSS from 'gulp-clean-css';
import gulpif from 'gulp-if';
import sourcemaps from 'gulp-sourcemaps';
//variables
config();
const PRODUCTION = yargs.argv.prod;
//STYLES
export const styles = () => {
return gulp.src(`src/scss/bundle.scss`)
.pipe(gulpif(!PRODUCTION, sourcemaps.init()))
.pipe(sass().on('error', sass.logError))
.pipe(gulpif(PRODUCTION, cleanCSS({compatibility:'ie8'})))
.pipe(gulpif(!PRODUCTION, sourcemaps.write()))
.pipe(gulp.dest(`${themeLocation}/css`))
}
Я хотел бы минимизировать мой css файл на производстве, но он не работает. В моем файле gulpfile я вижу только информацию:
Could not find a declaration file for module 'gulp-clean-css'. './node_modules/gulp-clean-css/index.js' implicitly has an 'any' type.
Try `npm install @types/gulp-clean-css` if it exists or add a new declaration (.d.ts) file containing `declare module 'gulp-clean-css';`
Я пытался установить @ types / gulp-clean- css, но получил только некоторые ошибки.
Как мне решить мою проблему? Спасибо!