Browse Source

fix babelconfig

pull/165/head
tangjinzhou 7 years ago
parent
commit
23a90001a2
  1. 3
      antd-tools/getBabelCommonConfig.js
  2. 5
      antd-tools/gulpfile.js
  3. 20
      webpack.base.config.js

3
antd-tools/getBabelCommonConfig.js

@ -2,12 +2,11 @@
module.exports = function (modules) {
const plugins = [
// require.resolve('babel-plugin-transform-vue-jsx'),
require.resolve('babel-plugin-transform-vue-jsx'),
require.resolve('babel-plugin-transform-es3-member-expression-literals'),
require.resolve('babel-plugin-transform-es3-property-literals'),
require.resolve('babel-plugin-transform-object-assign'),
require.resolve('babel-plugin-transform-object-rest-spread'),
require.resolve('babel-plugin-transform-decorators-legacy'),
]
plugins.push([require.resolve('babel-plugin-transform-runtime'), {
polyfill: false,

5
antd-tools/gulpfile.js

@ -123,9 +123,10 @@ function compile (modules) {
const source = [
'components/**/*.js',
'components/**/*.jsx',
'!components/vc-slider/**/*', // exclude vc-slider
]
const tsFilesStream = babelify(gulp.src(source), modules)
return merge2([less, tsFilesStream, assets])
const jsFilesStream = babelify(gulp.src(source), modules)
return merge2([less, jsFilesStream, assets])
}
gulp.task('dist', (done) => {

20
webpack.base.config.js

@ -2,6 +2,10 @@ const path = require('path')
const hljs = require('highlight.js')
const Token = require('markdown-it/lib/token')
const cheerio = require('cheerio')
const getBabelCommonConfig = require('./antd-tools/getBabelCommonConfig')
const babelConfig = getBabelCommonConfig(false)
babelConfig.plugins.push(require.resolve('babel-plugin-syntax-dynamic-import'))
const fetch = (str, tag) => {
const $ = cheerio.load(str, { decodeEntities: false, xmlMode: true })
@ -124,10 +128,26 @@ module.exports = {
{
test: /\.vue$/,
loader: 'vue-loader',
options: {
loaders: {
js: [
{ loader: 'babel-loader',
options: {
presets: ['env'],
plugins: [
'transform-vue-jsx',
'transform-object-rest-spread',
'syntax-dynamic-import',
],
}},
],
},
},
},
{
test: /\.(js|jsx)$/,
loader: 'babel-loader', exclude: /node_modules/,
options: babelConfig,
},
{
test: /\.(png|jpg|gif|svg)$/,

Loading…
Cancel
Save