webpack打包后的文件夹是空的_请问为什么webpack打包之后项目根目录下会出现0..,1..,2..的文件夹,有什么作用...

问 题

var htmlWebpackPlugin = require('html-webpack-plugin');

var path = require('path');

var webpack = require('webpack');

// var webpackMerge = require('webpack-merge');

module.exports = {

entry: './src/main.js',

output:{

filename:'./dist/bundle-[hash].js'

},

module: {

loaders: [

{

test: /\.css$/,

loaders: ["style-loader", "css-loader"],

},

{

test: /\.js$/,

loader: "babel-loader",

// include: '/src/static/views/'

},

{

test: /\.html$/,

loader: "html-loader"

},

{

test: /\.(png|jpg)$/,

loader: 'url-loader'

}

]

},

plugins: [

new webpack.ProvidePlugin({

_ : 'underscore',

$ : 'webpack-zepto',

Zepto : 'webpack-zepto',

'window.Zepto': 'webpack-zepto',

'window.$': 'webpack-zepto',

fastclick : 'fastclick'

})

],

externals: {

zepto: 'window.$'

}

};

解决方案

The reason you are seeing this is because the output.filename property is supposed to only contain the name of the file itself.

What is happening is that webpack is assuming the folder path before it, and then using the [hash] id of the lazy loaded bundles you are creating as the folder names.

My best guess would be that you could instead change this to:

const path = require('path');

module.exports = {

// ...

output: {

path: path.join(__dirname, "dist"),

filename: "bundle-[hash].js"

}

// ...

};

扫一扫关注IT屋

微信公众号搜索 “ IT屋 ” ,选择关注与百万开发者在一起

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值