Skip to content

Commit

Permalink
feat(core): Add inline image /files (base64)
Browse files Browse the repository at this point in the history
  • Loading branch information
Marinerer committed Dec 28, 2023
1 parent 45aff6f commit 2d5d5f9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
6 changes: 6 additions & 0 deletions packages/core/build/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const pugTemplate = require('gulp-pug')
const hbTemplate = require('gulp-hb')
const njkTemplate = require('gulp-nunjucks')
const artTemplate = require('gulp-art-tpl')
const base64 = require('gulp-dataurl')
const {
gulp,
_,
Expand Down Expand Up @@ -100,6 +101,11 @@ module.exports = function htmlTask(options = {}, done) {

// 5. 自定义处理流程
putProcesses(processes, options.plugins)

// 6. base64 处理
if (options.assetsInlineLimit?.limit > 0) {
processes.push(base64(options.assetsInlineLimit))
}

// 6. 文件指纹处理
if (manifest) {
Expand Down
8 changes: 7 additions & 1 deletion packages/core/build/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const concat = require('gulp-concat')
const sourcemaps = require('gulp-sourcemaps')
const filter = require('gulp-filter')
const replace = require('gulp-replace')
const base64 = require('gulp-dataurl')
const header = require('gulp-header')
const sass = require('gulp-sass')(require('sass'))
const less = require('gulp-less')
Expand Down Expand Up @@ -110,8 +111,13 @@ module.exports = function styleTask(options = {}, done) {

// 1. 自定义处理流程
putProcesses(processes, options.plugins)

// 2. base64 处理
if (options.assetsInlineLimit?.limit > 0) {
processes.push(base64(options.assetsInlineLimit))
}

// 2. postcss //!需配置 `postcss.config.js` 和 `.browserslistrc`
// 3. postcss //!需配置 `postcss.config.js` 和 `.browserslistrc`
const postcssPlugins = []
postcssPlugins.push(postcssEnv())
if (cssMinify) {
Expand Down
1 change: 1 addition & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"cssnano": "^6.0.1",
"gulp-art-tpl": "^1.3.0",
"gulp-concat": "^2.6.1",
"gulp-dataurl": "^1.2.1",
"gulp-ejs": "^5.1.0",
"gulp-eslint": "^6.0.0",
"gulp-filter": "^7.0.0",
Expand Down

0 comments on commit 2d5d5f9

Please sign in to comment.