Skip to content

Commit

Permalink
add gulp
Browse files Browse the repository at this point in the history
  • Loading branch information
myvin committed Nov 19, 2023
1 parent e6130a0 commit 17068ec
Show file tree
Hide file tree
Showing 7 changed files with 6,835 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules/
*.zip
build
build.pem
build.crx
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ A simple and minimalistic Chrome extension which can encode plain text to Base64

## How to Use

Right click on the selected text to choose `Base64 encode/decode "SELECTED TEXT"`. And the encoded/decoded text will be copied to clipboard. You can paste to where you need.
Right click on the selected text to choose `Base64 encode/decode "SELECTED TEXT"`. And the encoded/decoded text will be copied to clipboard. You can paste wherever you need.

## Buy Me a Coffee
## :coffee: Buy Me a Coffee

### BTC

Expand Down
2 changes: 1 addition & 1 deletion README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

在选中的文本上右键选择 `Base64 encode/decode "选中的文本"`,编码/解码后的结果就会复制到剪切板上。

## 请喝咖啡
## :coffee: 请喝咖啡

如果我的项目对你有帮助,可以请我喝杯咖啡。

Expand Down
106 changes: 106 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
const gulp = require('gulp')
const clean = require('gulp-clean')
const pump = require('pump')
const htmlmin = require('gulp-htmlmin')
const cleanCss = require('gulp-clean-css')
const autoprefixer = require('gulp-autoprefixer')
const babel = require('gulp-babel'),
uglify = require('gulp-uglify')

const buildPathName = 'build';
const path = {
images: {
src: 'src/images/**/*',
dest: `${buildPathName}/images`
},
html: {
src: 'src/**/*.html',
dest: `${buildPathName}/`
},
css: {
src: 'src/**/*.css',
dest: `${buildPathName}`
},
js: {
src: 'src/**/*.js',
dest: `${buildPathName}`
},
json: {
src: 'src/**/*.json',
dest: `${buildPathName}`
},
locales: {
src: 'src/_locales/**/*',
dest: `${buildPathName}/_locales`
}
}

const moveImages = () => {
return gulp.src(path.images.src)
.pipe(gulp.dest(path.images.dest))
}

const moveJson = () => {
return gulp.src(path.json.src)
.pipe(gulp.dest(path.json.dest))
}

const moveLocales = () => {
return gulp.src(path.locales.src)
.pipe(gulp.dest(path.locales.dest))
}

const css = () => {
return gulp.src(path.css.src)
.pipe(autoprefixer())
.pipe(cleanCss())
.pipe(gulp.dest(path.css.dest))
}
const js = () => {
return gulp.src(path.js.src)
.pipe(babel({
presets: ['@babel/env']
}))
.pipe(uglify())
.pipe(gulp.dest(path.js.dest))
}

const html = () => {
return gulp.src(path.html.src)
.pipe(htmlmin({
removeComments: true,
collapseWhitespace: true,
collapseBooleanAttributes: true,
removeEmptyAttributes: true,
removeScriptTypeAttributes: false,
removeStyleLinkTypeAttributes: true,
minifyJS: true,
minifyCSS: true
}))
.pipe(gulp.dest(path.html.dest))
}

const cleanBuild = () => {
return pump([
gulp.src(`./${buildPathName}`),
clean()
])
}
const watch = () => {
gulp.watch(path.images.src, moveImages)
gulp.watch(path.images.src, moveJson)
gulp.watch(path.images.src, moveLocales)
gulp.watch(path.html.src, html)
gulp.watch(path.css.src, css)
gulp.watch(path.js.src, js)
}

// module.exports = {
// html,
// js,
// css,
// watch
// }

module.exports.default = gulp.series(cleanBuild, gulp.parallel(moveImages, html, js, css, moveJson, moveLocales, watch))
module.exports.build = gulp.series(cleanBuild, gulp.parallel(moveImages, html, js, css, moveJson, moveLocales))
Loading

0 comments on commit 17068ec

Please sign in to comment.