Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add posthtml-px2rem #92

Merged
merged 1 commit into from
Dec 28, 2015
Merged

add posthtml-px2rem #92

merged 1 commit into from
Dec 28, 2015

Conversation

hzlzh
Copy link
Contributor

@hzlzh hzlzh commented Dec 28, 2015

No description provided.

voischev added a commit that referenced this pull request Dec 28, 2015
@voischev voischev merged commit 5c310e6 into posthtml:master Dec 28, 2015
@TrySound
Copy link
Contributor

@voischev posthtml - inline css processor. Really?

@voischev
Copy link
Member

Why not?

@voischev
Copy link
Member

Alternative posthtml-postcss + postcss plugins ;)

@TrySound
Copy link
Contributor

@voischev I'm for that. We need one or a few entry points like posthtml-postcss or posthtml-inline-styles which will pass css in callback. But posthtml plugins for this purpose is wrong way for ecosystem.

@voischev
Copy link
Member

@TrySound write about in weixin/posthtml-px2rem#3 issue

@hzlzh
Copy link
Contributor Author

hzlzh commented Dec 29, 2015

@TrySound Task blow is some of our project's Gulp Workflow
We'd like to get px-to-rem ready when moveHtml (form src to dist) run, so I add this posthtml plugin to do that.

// Build dist 流程
gulp.task('build', gulp.series(
    reset,
    compileLessBuild,
    replaceCSS,
    compileAutoprefixer,
    renameCSS,
    miniCSS,
    gulp.parallel(
        moveHtml,
        imageminImg,
        imageminSprite,
        uglifyJs
    )
));

// for HTML part
function moveHtml() {
    return gulp.src(paths.src.html, {base: paths.src.dir})
        .pipe(posthtml(posthtmlPx2rem({rootValue: 20, minPixelValue: 2})))
        .pipe(gulp.dest(paths.dist.dir));
}

// for CSS part
function compileAutoprefixer() {
    return gulp.src(paths.dist.cssAll)
        .pipe(postcss(
            [postcssAutoprefixer({browsers: ['last 5 versions']}),
                postcssDuplicates(),
                // add REM support
                postcssDuplicates({
                    root_value: '20', // base html{ font-zise: 20px; }
                    prop_white_list: [],
                    minPixelValue: 2
                })
            ]))
        .pipe(gulp.dest(paths.dist.css));
}

@TrySound
Copy link
Contributor

@hzlzh But was about posthtml->postcss->px-to-rem chain? Postcss for styles. Posthtml for markup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants