0

图片描述

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.$'
    }
};
李康 88
2017-06-26 提问

查看全部 2 个回答

75

已采纳

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"
    }
    // ...
};
1
回复 李康

惊现大神本人来答题啊!这位同学你中奖了

高阳Sunny · 2017年06月28日

1
回复 李康

想跟中国滴开发者多交流 ? 所以我们就把大神邀请过来啦

高阳Sunny · 2017年06月28日

1

厉害了

mxtob · 2017年06月29日

展开评论

推广链接