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

mina-loader: 为lang属性增加前置、主要、后置三个loader配置项 #49

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

run27017
Copy link
Contributor

@run27017 run27017 commented Dec 5, 2018

mina-loader的lang属性会完全覆盖对应tag下的loader配置,这会让明显的配置显得过于冗长,例如我想加入less-loader给lang=less,不得不这样写:

{
  loaders: {
    script: 'babel-loader',
    style: {
      loader: 'postcss-loader',
      options: {
        config: {
          path: resolve('./postcss.config.js')
        }
      }
    }
  },
  languages: {
    scss: [
      {
        loader: 'postcss-loader',
        options: {
          config: {
            path: resolve('./postcss.config.js')
          }
        }
      },
      'sass-loader'
    ]
  }
}

可以看出,关于postcss-loader的配置写了两遍。

我的想法是,给lang加入个后缀afterbeforecover,以给原始的postcss-loader prepend or append or override 其他的loaders。

languages: {
  "scss:after": "sass-loader", // 等价于[postcss-loader, sass-loader]
  "scss:before": "sass-loader", // 等价于[sass-loader, postcss-loader]
  "scss:after": "sass-loader", // 等价于[sass-loader],postcss-loader被替换了
  "scss": "sass-loader" // 考虑到最常用的情况,等价于sass:after
}

@TravisBuddy
Copy link

Hey @run27017,
Your changes look good to me!

View build log

TravisBuddy Request Identifier: 07011160-f876-11e8-a3fa-23497f13c755

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