mastilver / dynamic-cdn-webpack-plugin

Get your dependencies from a cdn rather than bundling them in your app
MIT License
343 stars 37 forks source link

Make it work with assets-webpack-plugin #31

Open mastilver opened 7 years ago

mastilver commented 7 years ago

https://github.com/kossnocorp/assets-webpack-plugin

aulisius commented 6 years ago

Was looking through the plugin. How exactly would this plugin work with assets-webpack-plugin ? The json that is emitted would contain the CDN urls for the libraries?

mastilver commented 6 years ago

yeah, same as manifest-webpack-plugin

I have no idea if there is something to do, maybe just a unit test would be enough?

aulisius commented 6 years ago

Hmm.

So for the following webpack config,

{
    context: path.resolve(__dirname, './fixtures/app'),

    output: {
        publicPath: '',
        path: path.resolve(__dirname, './fixtures/output/assets-webpack-plugin')
    },

    entry: {
        app: './single.js'
    },

    plugins: [
        new AssetsPlugin({
            filename: 'assets.json',
            useCompilerPath: true
        }),
        new DynamicCdnWebpackPlugin()
    ]
}

and single.js being

import React from 'react'

The JSON file that is generated contains the following.

{
    "app": {
        "js": "app.js"
    }
}

This kinda looks like the intended behaviour, but that means assets-webpack-plugin has no explicit effect on dynamic-cdn-webpack plugin.

mastilver commented 6 years ago

but the output, will not include react, right? No idea how they work, need to dig into the code

aulisius commented 6 years ago

Yes. I got that. But like I said

assets-webpack-plugin has no explicit effect on dynamic-cdn-webpack-plugin.

This becomes an non-issue.

mastilver commented 6 years ago

Does it? :thinking:

If app.js doesn't include react and the JSON doesn't reference it, how are developer going to know to include it or not?