Skip to content

support vue-loader options #3

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

Merged
merged 1 commit into from
May 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/webpack-config/addons/add-transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const makeLoaderName = name => (
/\-loader$/.test(name) ? name : `${name}-loader`
)

// 修改 babel-loader 的配置以适配 webpack2
// 修改 babel-loader 的配置以适配 webpack2 (enable tree-shaking,由 webpack 来做 module 格式的转换)
// 找到 ES2015 这个 preset,添加 { "modules": false }
// 注意后续可能要修改这边逻辑,考虑会对 import / export 进行转换的不一定只有 ES2015 这个 preset
const adaptBabelLoaderOptions = options => {
Expand Down Expand Up @@ -190,11 +190,13 @@ module.exports = (config, key, transform) => {
break

case transforms.vue:
// TODO: 对 vue-loader 中 babel-loader 的配置进行 adaptBabelLoaderOptions 的操作
config = update(config, {
module: { rules: {
$push: [
makeRule(extension, context, {
loader: 'vue'
loader: 'vue',
options: transform.config
})
]
} }
Expand Down
9 changes: 8 additions & 1 deletion preset-configs/vue.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
{
"transforms": {
"vue": "vue"
"vue": {
"transformer": "vue",
"config": {
"loaders": {
"js": "babel-loader?{\"presets\":[[\"ES2015\"]]}"
}
}
}
}
}