webpack配置如下啦:
const webpack = require('webpack')
const path = require('path')
const config = {
context: path.resolve(__dirname, '../src'),
entry: '../src/app.js',
output: {
path: path.resolve(__dirname, '../dist'),
filename: 'bundle.js'
},
module: {
rules: [{
test: /\.js$/,
include: path.resolve(__dirname, '../src'),
use: [{
loader: 'babel-loader',
options: {
presets: ['env']
}
}]
}]
},
plugins:[
]
}
module.exports = config
使用如上的webpack配置,打包app.js如下:
import a from './a'
import b from './b'
export{
a,
b
}
打包完发布npm,另一个项目使用该模块包,import {a} from xxx,却拿不到a或者b的值分别为undefined,这是为啥?(上述打包一切正常,已使用babel转换,依赖引入的也是转换后的es5代码)求指教!
相关分类