Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Webpack vendor dll Reference Error

Building webpack vendor dll and getting

Uncaught ReferenceError: vendors_9a2b8ee29a9e8dcdc486b49a360b9763 is not defined

The compiled code is coming out as

module.exports = vendors_9a2b8ee29a9e8dcdc486b49a360b9763;

//////////////////
// WEBPACK FOOTER
// external "vendors_9a2b8ee29a9e8dcdc486b49a360b9763"
// module id = 2
// module chunks = 0

it is missing the declaration and locating of something like

var angular = __webpack_require__(2)

module.exports = (__webpack_require__(3))(1)

I have no idea why this is and I've tried absolutely everything. Here is the plugins for my webpack config:

plugins: [
    new webpack.DllReferencePlugin({
        context: '.',
        manifest: require('./src/tmp/vendors-manifest.json')
    }),
],

and here is my dll config:

var webpack = require('webpack');
var packageJSON = require('./package.json');
var path = require('path');

module.exports = {
    entry: {
        vendors: Object.keys(packageJSON.devDependencies),
    },
    output: {
        path: path.join(__dirname, 'src/tmp'),
        filename: 'vendors.bundle.js',
        library: 'vendors_[hash]'
    },
    plugins: [
        new webpack.DllPlugin({
            path: 'src/tmp/[name]-manifest.json',
            name: 'vendors_[hash]'
        }),
    ]
};

index.html imports:

<script type="text/javascript" src="/src/tmp/vendors.bundle.js"></script>
<script type="text/javascript" src="/dist/js/app.js"></script>

Any ideas would be greatly appreciated! Thanks ahead of time!

like image 479
Alex Avatar asked Dec 14 '22 00:12

Alex


1 Answers

I had this problem. it solved by changing the context.

plugins: [
new webpack.DllReferencePlugin({
    context: path.join(__dirname, 'src/tmp'),
    manifest: require('./src/tmp/vendors-manifest.json')
})]
like image 132
Rostami Avatar answered Dec 16 '22 13:12

Rostami