|
2 | 2 | const compiler = require('mpvue-template-compiler')
|
3 | 3 | const htmlBeautify = require('js-beautify').html
|
4 | 4 |
|
| 5 | +const path = require('path') |
5 | 6 | const babel = require('babel-core')
|
6 | 7 | const { parseConfig, parseComponentsDeps } = require('./parse')
|
7 | 8 | const { genScript, genStyle, genPageWxml } = require('./templates')
|
@@ -91,7 +92,8 @@ function compileWxml (compiled, html) {
|
91 | 92 | // 针对 .vue 单文件的脚本逻辑的处理
|
92 | 93 | // 处理出当前单文件组件的子组件依赖
|
93 | 94 | function compileMPScript (script, optioins, moduleId) {
|
94 |
| - const { metadata } = babel.transform(script.content, { plugins: [parseComponentsDeps] }) |
| 95 | + const babelrc = optioins.globalBabelrc ? optioins.globalBabelrc : path.resolve('./.babelrc') |
| 96 | + const { metadata } = babel.transform(script.content, { extends: babelrc, plugins: [parseComponentsDeps] }) |
95 | 97 |
|
96 | 98 | // metadata: importsMap, components
|
97 | 99 | const { importsMap, components: originComponents } = metadata
|
@@ -135,7 +137,9 @@ const startPageReg = /^\^/
|
135 | 137 |
|
136 | 138 | function compileMP (content, optioins) {
|
137 | 139 | const { resourcePath, emitError, emitFile, emitWarning, resolve, context } = this
|
138 |
| - const { metadata } = babel.transform(content, { plugins: [parseConfig] }) |
| 140 | + |
| 141 | + const babelrc = optioins.globalBabelrc ? optioins.globalBabelrc : path.resolve('./.babelrc') |
| 142 | + const { metadata } = babel.transform(content, { extends: babelrc, plugins: [parseConfig] }) |
139 | 143 |
|
140 | 144 | // metadata: config
|
141 | 145 | const { config, rootComponent } = metadata
|
|
0 commit comments