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

fix(taro-cli): 修复小程序端非生产模式下不应用 csso 配置问题 close #3622 #3623

Merged
merged 1 commit into from
Jul 2, 2019
Merged

fix(taro-cli): 修复小程序端非生产模式下不应用 csso 配置问题 close #3622 #3623

merged 1 commit into from
Jul 2, 2019

Conversation

Garfield550
Copy link
Collaborator

这个 PR 做了什么? (简要描述所做更改)

修复小程序端非生产模式(dev)下,配置了 csso 但是不能应用的问题。

这个 PR 是什么类型? (至少选择一个)

这个 PR 满足以下需求:

  • 提交到 master 分支
  • Commit 信息遵循 Angular Style Commit Message Conventions
  • 所有测试用例已经通过
  • 代码遵循相关包中的 .eslintrc, .tslintrc, .stylelintrc 所规定的规范
  • 在本地测试可用,不会影响到其它功能

这个 PR 涉及以下平台:
理论上这个 PR 可以应用到所有小程序端

  • 微信小程序
  • 支付宝小程序
  • 百度小程序
  • 头条小程序
  • QQ 轻应用
  • 快应用平台(QuickApp)
  • Web 平台(H5)
  • 移动端(React-Native)

其它需要 Reviewer 或社区知晓的内容:

测试步骤

测试用例 app.scss 如下:

/* I'm a comment 1. */
/*! I'm a comment 2. */
/** I'm a comment 3. */
// I'm a comment 4.

.test-class {
  /* I'm a comment 5. */
  /*! I'm a comment 6. */
  /** I'm a comment 7. */
  // I'm a comment 8.
  color: red;
}

dev 模式使用命令 ~/Projects/Test/taro/packages/taro-cli/bin/taro build --type weapp --watch
prod 模式使用命令 ~/Projects/Test/taro/packages/taro-cli/bin/taro build --type weapp

  1. taro init 一个使用 default 模版的项目

  2. config/index.js 使用默认配置保持不变

  3. config/dev.js 为默认,如下:

module.exports = {
  env: {
    NODE_ENV: '"development"'
  },
  defineConstants: {},
  weapp: {},
  h5: {}
};

3.1 app.wxss 结果:

/* I'm a comment 1. */
/*! I'm a comment 2. */
/** I'm a comment 3. */
.test-class {
  /* I'm a comment 5. */
  /*! I'm a comment 6. */
  /** I'm a comment 7. */
  color: red; }
  1. 修改 config/dev.js 配置,启用 csso,如下:
module.exports = {
  env: {
    NODE_ENV: '"development"'
  },
  defineConstants: {},
  weapp: {},
  h5: {},
  plugins: {
    csso: {
      enable: true
    }
  }
};

4.1 app.wxss 结果:

/*! I'm a comment 2. */
.test-class{color:red}
  1. 修改 config/dev.js 配置,启用 csso,并配置 compress 选项,如下:
module.exports = {
  env: {
    NODE_ENV: '"development"'
  },
  defineConstants: {},
  weapp: {},
  h5: {},
  plugins: {
    csso: {
      enable: true,
      config: {
        comments: false
      }
    }
  }
};

5.1 app.wxss 结果:

.test-class{color:red}
  1. config/prod.js 为默认,如下:
module.exports = {
  env: {
    NODE_ENV: '"production"'
  },
  defineConstants: {},
  weapp: {},
  h5: {
    /**
     * 如果h5端编译后体积过大,可以使用webpack-bundle-analyzer插件对打包体积进行分析。
     * 参考代码如下:
     * webpackChain (chain) {
     *   chain.plugin('analyzer')
     *     .use(require('webpack-bundle-analyzer').BundleAnalyzerPlugin, [])
     * }
     */
  }
};

6.1 app.wxss 结果:

/*! I'm a comment 2. */
.test-class{color:red}

@luckyadam
Copy link
Member

Good!

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.

2 participants