Categories
reactjs webpack

webpackJsonp is not defined

Codes

This is my webpack.babel.js

entry section:

entry: {
vendor: [
"react",
"react-dom"
]
}
// 自动获取路径(主动获取写的逻辑代码)
let files = glob.sync('./src/**/index.js'),
newEntries = files.reduce(function (memo , file) {
let name = /.*\/(.*?)\/index\.js/.exec(file)[1];
memo[name] = entry(name);
return memo;
}, {});
config.entry = Object.assign({} , config.entry , newEntries);
function entry(name) {
return './src/js/' + name + '/index.js';
}

output section:

output: {
path: path.join(__dirname,"/dist/js/"),
filename: "[name].js"
},

module section:

 module: {
// 将非js的资源 或者 非es5 资源 转化为合适的 js 资源
loaders: [{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel',
query: {
presets: [
'es2015',
'stage-0',
'react'
]
}
}]
},
// 第三方库合并
plugins: [
new webpack.optimize.CommonsChunkPlugin('vendor' , 'vendor.bundle.js')
]
}

I use webpack loading in my React code (home.js)

Problem

I want to load my script however I meet some ReferenceError.

Uncaught ReferenceError: webpackJsonp is not defined

I am loading vendor.bundle.js bundle file right before home.js

<script src="https://www.faqcode4u.com/faq/80313/dist/js/vendor.bundle.js"></script>
<script src="https://www.faqcode4u.com/faq/80313/dist/js/home.js"></script>