packages/loader/src/index.js
function getBabelLoader(projectRoot, name, isDev) {
  name = name || 'vux'
  if (!projectRoot) {
    projectRoot = path.resolve(__dirname, '../../../')
    if (/\.npm/.test(projectRoot)) {
      projectRoot = path.resolve(projectRoot, '../../../')
    }
  }

  let componentPath
  let regex
  if (!isDev) {
    componentPath = fs.realpathSync(projectRoot + `/node_modules/${name}/`) // https://github.com/webpack/webpack/issues/1643
    regex = new RegExp(`node_modules.*${name}.src.*?js$`)
  } else {
    componentPath = projectRoot
    regex = new RegExp(`${projectRoot}.src.*?js$`)
  }

  return {
    test: regex,
    loader: 'babel-loader',
    include: componentPath
  }
}
function getBabelLoader(projectRoot, name, isDev) {
  name = name || 'vux'
  if (!projectRoot) {
    projectRoot = path.resolve(__dirname, '../../../')
    if (/\.npm/.test(projectRoot)) {
      projectRoot = path.resolve(projectRoot, '../../../')
    }
  }

  let componentPath
  let regex
  if (!isDev) {
    componentPath = fs.realpathSync(projectRoot + `/node_modules/${name}/`) // https://github.com/webpack/webpack/issues/1643
    regex = new RegExp(`node_modules.*${name}.src.*?js$`)
  } else {
    componentPath = projectRoot
    regex = new RegExp(`${projectRoot}.src.*?js$`)
  }

  return {
    test: regex,
    loader: 'babel-loader',
    include: componentPath
  }
}
function getBabelLoader ( projectRoot , name , isDev ) { name = name || 'vux' if ( ! projectRoot ) { projectRoot = path . resolve ( __dirname , '../../../' ) if ( / \.npm / . test ( projectRoot ) ) { projectRoot = path . resolve ( projectRoot , '../../../' ) } } let componentPath let regex if ( ! isDev ) { componentPath = fs . realpathSync ( projectRoot + ` ${ name } ` ) // https://github.com/webpack/webpack/issues/1643
 regex = new RegExp ( ` ${ name } ` ) } else { componentPath = projectRoot regex = new RegExp ( ` ${ projectRoot } ` ) } return { test : regex , loader : 'babel-loader' , include : componentPath } }
use babel so component's js can be compiled
use babel so component s js can be compiled