Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 带有CommonChunk和extract text网页包插件的网页包缺少模块_Javascript_Webpack_Commonschunkplugin - Fatal编程技术网

Javascript 带有CommonChunk和extract text网页包插件的网页包缺少模块

Javascript 带有CommonChunk和extract text网页包插件的网页包缺少模块,javascript,webpack,commonschunkplugin,Javascript,Webpack,Commonschunkplugin,我正在关注,并试图得到一个非常简单的网页包包,其中有1个入口点和2个块。因为这两个块都需要jquery和Mustach,所以我使用CommonChunkPlugin将公共依赖项向上移动到主bundle文件,就像在教程中一样。我还使用从块中提取样式,并将它们放在一个单独的CSS文件中 My webpack.config.js: var ExtractPlugin = require("extract-text-webpack-plugin"); var plugins = [ new Ex

我正在关注,并试图得到一个非常简单的网页包包,其中有1个入口点和2个块。因为这两个块都需要jquery和Mustach,所以我使用CommonChunkPlugin将公共依赖项向上移动到主bundle文件,就像在教程中一样。我还使用从块中提取样式,并将它们放在一个单独的CSS文件中

My webpack.config.js:

var ExtractPlugin = require("extract-text-webpack-plugin");
var plugins = [
    new ExtractPlugin("bundle.css"),
    new webpack.optimize.CommonsChunkPlugin({
        name: "vendors", //move dependencies to our main bundle file
        children: true, //look for dependencies in all children
        minChunks: 2 //how many times a dependency must come up before being extracted
    })
];

module.exports = {
    /*...*/
    entry: "./src/index.js",
    output: {
        /*...*/
    },
    plugins: plugins,
    module: {
        loaders: [
            /*...*/
            {
                test: /\.scss$/,
                loader: ExtractPlugin.extract("style", "css!sass")
                //loaders: ["style", "css", "sass"]
            },
            /*...*/
        ]
    }
};
入口点中的相关代码(我使用ES6语法和babel):

chunk1和chunk2看起来都像这样:

import $ from "jquery";
import Mustache from "mustache";
/*import chunk templates and scss*/

export default class /*Chunk1or2*/ {
    render() {
        $(/*some stuff*/).html(Mustache.render(/*some other stuff*/));
    }
}
index.html:

<html>
<head>
    <link rel="stylesheet href="build/bundle.css">
</head>
<body>
    <script src="/build/main.js"></script>
</body>
</html>


发布index.htmlDone,还添加了一些相关代码。请尝试输入输出目录。我怀疑main.js没有生成。据我所知,它肯定是由浏览器生成和加载的,在清除缓存和所有内容后,它会显示在源文件中。如果在chrome中打开,您应该能够转到发生异常的行号
<html>
<head>
    <link rel="stylesheet href="build/bundle.css">
</head>
<body>
    <script src="/build/main.js"></script>
</body>
</html>