numical / script-ext-html-webpack-plugin

Enhances html-webpack-plugin functionality with different deployment options for your scripts including 'async', 'preload', 'prefetch', 'defer', 'module', custom attributes, and inlining.
MIT License
588 stars 105 forks source link

Circular reference detected (v1.8.5) #37

Closed BairDev closed 6 years ago

BairDev commented 7 years ago

When we add the ScriptExtHtmlWebpac plugin to our configuration, Grunt complains with this error. Here is the full output:

Warning: Circular reference detected (.webpack.dev.plugins[1].options.compilationOptions.plugins[1].options)

Here is our Webpack config:

return {
    'cache'   : true,
    'devtool' : 'cheap-module-source-map',
    'module'  : {
        'rules' : [
            {
                'test' : /language\/\w+_\w+\/.*\.json$/,
                'use'  : {
                    'loader' : 'lang-loader'
                }
            }
        ]
    },
    'resolve' : {
        'modules' : [
            oConfig.sSymlinkPath,
            oConfig.sNodeModulePath
        ],
        'alias' : oAlias
    },
    'resolveLoader' : {
        'modules' : [
            oConfig.sSymlinkPath,
            oConfig.sNodeModulePath
        ],
        'alias' : {
            'text'        : 'raw-loader',
            'lang-loader' : path.resolve(oConfig.sWebpackPath, 'lang-loader.js')
        }
    },
    'entry' : {
        'main' : './' + oConfig.sModuleName + '.js'
    },
    'output' : {
        'filename' : '[name].[chunkhash].js',
        'path'     : oConfig.sServePath
    },
    'plugins' : [
        new HtmlWebpackPlugin({
            'template' : path.resolve(oConfig.sSymlinkPath, oConfig.sAppPath, 'index.html')
        }),

        new ScriptExtHtmlWebpackPlugin({
            'defaultAttribute' : 'defer'
        }),

        new webpack.optimize.CommonsChunkPlugin({
            'name'      : 'vendor',
            'minChunks' : function(module)
            {
                // console.log(module.context);
                return /node_modules/.test(module.context) ||
                    /can\/can/.test(module.context) ||
                    /bootstrap\/js/.test(module.context);
            }
        }),
        new webpack.optimize.CommonsChunkPlugin({
            'name'      : 'manifest',
            'minChunks' : Infinity
        }),

        new webpack.ProvidePlugin(oConfig.oProvidePlugin)
    ]
};

Few version:

numical commented 7 years ago

Hi, This seems to be a Grunt limitation. A google search show a few aborted attempts to fix it. The best I can offer right now is this workaround from the official team. Let me know if it works for you

numical commented 7 years ago

@BairDev - hello..? Did the Grunt workaround help?

BairDev commented 7 years ago

@numical Sorry for the late answer and for the delay, but our projects are actually quite complex, so I need some extra time for checking the workaround. I can do this next week hopefully. Thanks for your patience.

fintechbydesign commented 6 years ago

@BairDev - OK to close this issue? I assume you have worked around this issue..

BairDev commented 6 years ago

@fintechbydesign Year this is totally fine. I'll try that thing later, thanks anyway.