为了账号安全,请及时绑定邮箱和手机立即绑定

webpack深入与实战

难度中级
时长 3小时21分
学习人数
综合评分9.60
259人评价 查看评价
9.8 内容实用
9.5 简洁易懂
9.5 逻辑清晰
开辟新的战场!
ERROR in Template execution failed: TypeError: Cannot read property 'entry' of undefined

ERROR in TypeError: Cannot read property 'entry' of undefined
module: {
rules: [
{
test: /\.js$/,
include:/("\.\/src")/,
use: {
loader: 'babel-loader',
options: {
presets: ['env']
}
}
module: {
rules: [
{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
options: {
presets: ['env']
}
}
}
]
},

最新回答 / 冰大神丶
plugins: [        /*new webpack.ResolverPlugin([            new webpack.ResolverPlugin.DirectoryDescriptionFilePlugin("bower.json", ["main"])        ], ["normal", "loader"])*/        new htmlWebpackPlugin({        template:'index.html',        filename:...
课程很赞,老师很棒
翻前面的,瞎捣鼓,webpack2.0这样写貌似是没问题的。。在webpack.config.js里。也不用加什么
module:{rules:[{test:/\.css$/, use:[{loader:'style-loader',}, {loader:'css-loader', },{loader:'postcss-loader',options:{plugins:function () {return [require('autoprefixer')({browsers:["last 5 versions"]})];} }} ], }],},
配置文件如下,可以通过:
module.exports = {
entry: {
main: './src/script/main.js',
a: './src/script/a.js'
},
output:{
path: __dirname+'/dist/js',
filename: '[name].js' //此处为修改的地方
}
}
config.js配置信息如下可以编译:
module.exports = {
entry: './src/script/main.js',
output:{
path: __dirname+'/dist/js',
filename: 'bundle.js'
}
}

最赞回答 / one_day521
绝对路径问题const path = require('path');module.exports = {    entry: './src/script/main.js',    output: {        path: path.resolve('./dist/js'),        filename: 'bundle.js'    }}
Webpack 2 的新语法

module:{
rules:[
{
test:/\.js$/,
loader:'babel-loader',
exclude:/node_modules/,
include:/src/
}
]
},

package.json中:
"babel":{
"presets":["env"]
},

最赞回答 / xlelou
你的 plugins: 后面应该是中括号,你用了花括号  plugins:[]
由于版本问题,这里要这样写 module.exports = { entry:{ main:'./src/script/main.js', a:'./src/script/a.js' }, output:{ path: __dirname + '/dist/js', filename:'[name].js' //视频中的bundle要改成这样 } }
课程须知
1、对模块化开发有一些了解 2、使用过 node 对 npm 有基本的了解 3、对打包有一个基本的概念
老师告诉你能学到什么?
1、模块化的开发 2、webpack 的 CLI (命令行) 3、webpack 如何在项目中打包 4、webpack 如何处理项目中的资源文件

微信扫码,参与3人拼团

微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号

友情提示:

您好,此课程属于迁移课程,您已购买该课程,无需重复购买,感谢您对慕课网的支持!

本次提问将花费2个积分

你的积分不足,无法发表

为什么扣积分?

本次提问将花费2个积分

继续发表请点击 "确定"

为什么扣积分?

举报

0/150
提交
取消