Skip to content

Instantly share code, notes, and snippets.

@adamhenson
Last active February 27, 2019 14:10
Show Gist options
  • Save adamhenson/96ff7e07239d890a157e407863977d0b to your computer and use it in GitHub Desktop.
Save adamhenson/96ff7e07239d890a157e407863977d0b to your computer and use it in GitHub Desktop.

Revisions

  1. adamhenson revised this gist Feb 27, 2019. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions webpack.config.js
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,5 @@
    import webpack from 'webpack';
    import path from 'path';

    const common = {
    // imagine your configuration here
  2. adamhenson revised this gist Feb 21, 2019. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions webpack.config.js
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    import webpack from 'webpack';

    const common = {
    // imagine your configuration here
    };
    @@ -40,6 +42,9 @@ export default {
    plugins: [
    // this is too...
    new LoadablePlugin(),
    new webpack.DefinePlugin({
    LOADABLE_STATS: JSON.stringify(path.resolve(__dirname, '../build/loadable-stats.json')),
    }),
    ...common.plugins,
    ],
    optimization: {
  3. adamhenson revised this gist Feb 21, 2019. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions webpack.config.js
    Original file line number Diff line number Diff line change
    @@ -42,5 +42,11 @@ export default {
    new LoadablePlugin(),
    ...common.plugins,
    ],
    optimization: {
    // https://webpack.js.org/plugins/split-chunks-plugin/#optimization-splitchunks
    splitChunks: {
    chunks: 'all',
    },
    },
    ...common,
    };
  4. adamhenson revised this gist Feb 21, 2019. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion webpack.config.js
    Original file line number Diff line number Diff line change
    @@ -38,8 +38,9 @@ export default {
    ],
    },
    plugins: [
    ...common.plugins,
    // this is too...
    new LoadablePlugin(),
    ...common.plugins,
    ],
    ...common,
    };
  5. adamhenson revised this gist Feb 21, 2019. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions webpack.config.js
    Original file line number Diff line number Diff line change
    @@ -3,11 +3,11 @@ const common = {
    };

    const plugins = [
    // imagine your presets here
    // imagine your Babel plugins here
    ];

    const presets = [
    // imagine your presets here
    // imagine your Babel presets here
    ];

    export default {
  6. adamhenson created this gist Feb 21, 2019.
    45 changes: 45 additions & 0 deletions webpack.config.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,45 @@
    const common = {
    // imagine your configuration here
    };

    const plugins = [
    // imagine your presets here
    ];

    const presets = [
    // imagine your presets here
    ];

    export default {
    entry: [
    '@babel/polyfill',
    './src/client',
    ],
    module: {
    rules: [
    {
    test: /\.js$/,
    exclude: /node_modules/,
    use: [
    {
    loader: 'babel-loader',
    options: {
    plugins: [
    // this is the important part...
    '@loadable/babel-plugin',
    ...plugins,
    ],
    presets,
    },
    },
    ],
    },
    ...common.plugins.module.rules,
    ],
    },
    plugins: [
    ...common.plugins,
    new LoadablePlugin(),
    ],
    ...common,
    };