Giter Site home page Giter Site logo

如何使用postcss-pxtorem about roadhog HOT 7 CLOSED

sorrycc avatar sorrycc commented on September 26, 2024
如何使用postcss-pxtorem

from roadhog.

Comments (7)

sorrycc avatar sorrycc commented on September 26, 2024

一样的,roadhog 支持 webpack.config.js

from roadhog.

semicoder avatar semicoder commented on September 26, 2024

那webpack.config.js 和 .roadhogrc 是同时配置使用的还是只能单独使用?
能给个现在版本的使用webpack.config.js的例子吗?

之前这么写的, 关闭了css moudle(不好用,不知道怎么和ui库配合使用,覆盖样式之类的)

const pxtorem = require('postcss-pxtorem');
const webpack = require('atool-build/lib/webpack');

module.exports = function(webpackConfig, env) {
  webpackConfig.babel.plugins.push('transform-runtime');

  // Support hmr
  if (env === 'development') {
    webpackConfig.devtool = '#eval';
    webpackConfig.babel.plugins.push('dva-hmr');
  } else {
    webpackConfig.babel.plugins.push('dev-expression');
  }

  // Don't extract common.js and common.css
  webpackConfig.plugins = webpackConfig.plugins.filter(function(plugin) {
    return !(plugin instanceof webpack.optimize.CommonsChunkPlugin);
  });

  // Support antd
  webpackConfig.babel.plugins.push(['import', {
    libraryName: 'antd-mobile',
    style: 'css'
  }])

  webpackConfig.externals ={
    'AMap': 'AMap',
    'wx': 'wx',
    'OSS': 'OSS'
  }

  webpackConfig.postcss.push(pxtorem({
    rootValue: 100,
    propWhiteList: [],
  }));

  return webpackConfig;
};

from roadhog.

sorrycc avatar sorrycc commented on September 26, 2024

可以同时用的,webpack.config.js 的配置在 .roadhogrc 之后。

from roadhog.

sorrycc avatar sorrycc commented on September 26, 2024

有问题再 reopen

from roadhog.

jozhi avatar jozhi commented on September 26, 2024

@sorrycc 有个问题: .roadhogrc 中如何配置 pxtorem。
@semicoder 贴出来的代码我试用了下发现有 bug: webpackConfig.postcss 的类型是 function,导致 push 方法报错,这个可能是哪里的问题?

roadhog的版本是 0.5.2

from roadhog.

sorrycc avatar sorrycc commented on September 26, 2024

@jozhiextraPostCSSPlugins 配置。

from roadhog.

jozhi avatar jozhi commented on September 26, 2024

@sorrycc 没头没尾的有这么一句真的是让哀家不知所措,不知道怎么往项目上用。 如果能贴出来完整的配置会不会更好一点。。

目前临时解决方案 #134 ,如果可以请尽快修复一下。

from roadhog.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.