Skip to content
This repository has been archived by the owner on Aug 8, 2019. It is now read-only.

can DllPlugin and DllReferencePlugin run in browser by use the style of 'commonjs2' instead of 'insert a script tag in html' ? #89

Open
klouskingsley opened this issue Dec 21, 2016 · 2 comments

Comments

@klouskingsley
Copy link

I try to use commonjs2 style in DllPlugin and the browser return an error

Uncaught ReferenceError: require is not defined

here is my config files

  • webpack dll config
var webpack = require('webpack')

module.exports = {
    output: {
        path: './dll',
        filename: '[name].js',
        library: '[name]',
        libraryTarget: 'commonjs2'
    },
    entry: {
        test: ['./js/lib/browser.js']
    },
    plugins: [
        new webpack.DllPlugin({
            path: './dll/[name]-manifest.json',
            name: '[name]',
            context: __dirname
        })
    ]
}
  • webpack config fle
var webpack = require('webpack')

module.exports = {
    output: {
        path: __dirname,
        filename: '[name].bundle.js',
    },
    entry: {
        app: ['./app.js']
    },
    plugins: [
        new webpack.DllReferencePlugin({
            manifest: require('./dll/test-manifest.json'),
            context: __dirname,
            sourceType: 'commonjs2',
            name: './dll/test.js'
        })
    ]
}
@captain-yossarian
Copy link

Does somebody find solution here?

@yousefallaban
Copy link

I had the same error 🤔

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants