react.js - CSS独立打包报错Chunk.entry was removed. Use hasRuntime() 是什么原因?

查看:389
本文介绍了react.js - CSS独立打包报错Chunk.entry was removed. Use hasRuntime() 是什么原因?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

麻烦大家帮我解决。。我的webpack.config.js是在项目根目录有一个,在特定的功能文件夹一个,打包时候,在根目录运行webpack命令,js文件里面引入X文件夹的另一个webpack.config.js,这样我可以通过切换文件夹路径决定打包哪个模块。

!!!!下面是X文件夹里面的config

const webpack = require('webpack');
const filePath = './BehaviorHabit/src/main/webapp/resources/wx/js/assessPage_demo';
var ExtractTextPlugin = require('extract-text-webpack-plugin');

module.exports = {
    // devtool: 'cheap-module-eval-source-map',
    entry:  {
        './BehaviorHabit/src/main/webapp/resources/wx/js/common/commonPlugins': ["jquery", "jquery.mmenu", "react", "react-dom"],
        './BehaviorHabit/src/main/webapp/resources/wx/js/assessPage_demo/dist/bundle': filePath + '/js/assessEntry.js'

    },
    output: {
        filename: '[name].js'
    },
    module: {
        loaders:[
        { 
            test: /\.js|js[x]?$/,
            exclude: /node_modules/,
            query: {presets: ['es2015','react']} ,
            loader:"babel"
            // loader: 'babel-loader?presets[]=es2015&presets[]=react',
        },
        // { 
        //     test: /\.css$/,    
        //     // modules&localIdentName=[local] 加上modules表示使用css模块化 、
        //     // localIdentName是对css命名,[name]模块(文件)名 [local]类名 [hash:base64:5] hash值
        //     loader: 'style!css?modules&localIdentName=[local]'
        //     // &localIdentName=[name]localIdentName=[name]__[local]___[hash:base64:5]
        //     // loader: 'style-loader!css-loader'

        // },
        {
            test: /\.css$/,
            loader: ExtractTextPlugin.extract("style-loader", "css-loader")
        },
        // { 
        //     test: /\.(png|jpg)$/, 
        //     loader: 'url-loader?limit=8192'
        // },
        { test: /\.(gif|jpg|png|woff|svg|eot|ttf)\??.*$/, loader: 'url-loader?limit=50000&name=[path][name].[ext]'}
        ]
    },
    plugins: [    
    new webpack.optimize.CommonsChunkPlugin({        
        name: ['./BehaviorHabit/src/main/webapp/resources/wx/js/common/commonPlugins', './BehaviorHabit/src/main/webapp/resources/wx/js/common/manifest'],
        minChunks : Infinity
    }),    
    new webpack.optimize.UglifyJsPlugin({
        compress: {
            warnings: false
        }
    }),
    new webpack.ProvidePlugin({
        "React": "react",
        "ReactDOM": "react-dom",
        $ : "jquery",  

    }),    
    new ExtractTextPlugin("./style.css"),
    ],
};


!!!这里是根目录的config  cfg就是上面的X文件夹的config.js 就是上面那段代码

const webpack = require('webpack')
var ExtractTextPlugin = require('extract-text-webpack-plugin');

var cfg = require('./BehaviorHabit/src/main/webapp/resources/wx/js/assessPage_demo/webpack.config.js');
module.exports = {
    // devtool: 'cheap-module-eval-source-map',
    entry: cfg.entry,
    output: cfg.output,
    module: cfg.module,        
    plugins: cfg.plugins
};

运行webpack后报错是Chunk.entry was removed. Use hasRuntime() ,请问这是什么原因?找了很久找不到答案。。请问大神这个报错应该怎么解决T T

ps: style-loader css-loader extract-text-webpack-plugin这些都已经install了。。。

解决方案

问题解决了
之前解决了,因为把方案放在了评论里面,还有很多热心的朋友帮忙解决,现在把评论里面的解决方法再发一次.
是extract-text-webpack-plugin版本不对 其实社区里面已经有人提过这个答案了,只是可能当时的npm命令和现在有点出入
把extract-text-webpack-plugin移除后 执行命令
npm install extract-text-webpack-plugin@^2.0.0-beta.4
最后的beta.4是必要的 之前就因为直接写beta没有.4 也没注意看报错命令
结果花了很多时间。。。

这篇关于react.js - CSS独立打包报错Chunk.entry was removed. Use hasRuntime() 是什么原因?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆