1. First installation environment
1. Install gulp: npm install gulp
2.安装gulp-clean-css npm install gulp-clean-css
3.安装gulp-css-wrap npm install gulp-css-wrap
4.npm i gulp merge-stream // use multiple file sources in a single task
Then the root directory of the new project gulpfile.js file, write the following code
var path = require('path') var gulp = require('gulp') var cleanCSS = require('gulp-clean-css') var cssWrap = require('gulp-css-wrap') var go = require ( "go-stream '); gulp.task('css-wrap', function () { var light = gulp.src(path.resolve('./src/assets/scss/theme/light/index.css')) / * Find the need to add css file namespaces, support for regular expressions * / .pipe(cssWrap({ selector: '.theme-light' / * add namespace * / })) .pipe(cleanCSS()) .pipe (gulp.dest ( './ src / assets / scss / theme / css / light')); / * store directory * / var dark = gulp.src(path.resolve('./src/assets/scss/theme/dark/index.css')) / * Find the need to add css file namespaces, support for regular expressions * / .pipe(cssWrap({ selector: '.theme-dark' / * add namespace * / })) .pipe(cleanCSS()) .pipe (gulp.dest ( './ src / assets / scss / theme / css / dark')); / * store directory * / return merge(light,dark); })
Then run the command line: gulp css-wrap is generated through the class name of the add css file it