cats.js:
var cats = ['dave','henry','martha']; module.exports = cats;
app.js:
cats = require('./cats.js');console.log(cats);
webpack.config.js :
module.exports = { entry: './app.js', output: { path: path.resolve(__dirname,'dist'), publicPath: '/assets/', filename: 'bundle.js' }, module: { loaders: [{ test: /\.js$/, include: [ path.join(__dirname,'src') ], exclude: /node_modules/, loader: 'babel-loader', }] } };
运行:./node_modules/.bin/webpack-dev-server --inline
运行后webpack-dev-server后打开也页面报错:
bundle.js:7531 Uncaught ReferenceError: cats is not defined
明明都require怎么会没定义呢 刚开始接触webpack,希望各位能够帮帮小弟
墨色风雨
相关分类