How to use @loadable/webpack-plugin - 8 common examples

To help you get started, we’ve selected a few @loadable/webpack-plugin examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github reworkjs / reworkjs / src / internals / webpack / WebpackBase.js View on Github external
removeComments: true,
          collapseWhitespace: true,
          removeRedundantAttributes: true,
          useShortDoctype: true,
          removeEmptyAttributes: true,
          removeStyleLinkTypeAttributes: true,
          keepClosingSlash: true,
          minifyJS: true,
          minifyCSS: true,
          minifyURLs: true,
        },
      }),

      // Dump chunk mapping and entryPoints so we can determine which client chunks to send depending on which
      // chunks were imported during server-side rendering
      new LoadablePlugin({
        writeToDisk: true,
      }),
    ];

    // if (!this.isServer()) {
    //   plugins.push(
    //     new PolyfillInjectorPlugin({
    //       polyfills: ['Promise'],
    //     }),
    //   );
    // }

    if (this.isDev) {
      plugins.push(
        // enable hot reloading.
        new webpack.HotModuleReplacementPlugin(),
github mozilla / addons-frontend / webpack-common.js View on Github external
// This swaps the server side window object with a standard browser window.
    new webpack.NormalModuleReplacementPlugin(
      /core\/window/,
      'core/browserWindow.js',
    ),
    new CircularDependencyPlugin({
      exclude: /node_modules/,
      failOnError: true,
    }),
  ];

  if (includeLoadablePlugin) {
    // We need this file to be written on disk so that our server code can read
    // it. In development mode, webpack usually serves the file from memory but
    // that's not what we want for this file.
    plugins.push(new LoadablePlugin({ writeToDisk: true }));
  }

  if (excludeOtherAppLocales) {
    plugins.push(
      // This allow us to exclude locales for other apps being built.
      new webpack.ContextReplacementPlugin(
        /locale$/,
        new RegExp(`^\\.\\/.*?\\/${appName}\\.js$`),
      ),
    );
  }

  return plugins;
}
github react-zeroconfig / react-zeroconfig / src / webappScripts / startBrowser.ts View on Github external
style: {
              test: m => m.constructor.name === 'CssModule',
              name: styleFileName,
              chunks: 'all',
              enforce: true,
            },
          },
        },
      },
      
      plugins: [
        new HotModuleReplacementPlugin(),
        
        // create loadable-stats.json when server side rendering enabled
        ...(extend.serverSideRendering ? [
          new LoadablePlugin({
            filename: path.join(output, 'loadable-stats.json'),
            writeToDisk: true,
          }),
        ] : []),
        
        // create html files
        ...(extend.templateFiles.length > 0 ? extend.templateFiles.map(templateFile => {
          const extname: string = path.extname(templateFile);
          const filename: string = path.basename(templateFile, extname);
          
          return new HtmlWebpackPlugin({
            template: path.join(cwd, 'src', app, templateFile),
            filename: filename + '.html',
          });
        }) : []),
      ],
github react-zeroconfig / react-zeroconfig / src / webappScripts / buildBrowser.ts View on Github external
// create css files
        new MiniCssExtractPlugin({
          filename: `${chunkPath}[name].[hash].css`,
          chunkFilename: `${chunkPath}[name].[hash].css`,
        }),
        
        // create size report
        new BundleAnalyzerPlugin({
          analyzerMode: 'static',
          reportFilename: path.join(output, 'size-report.html'),
          openAnalyzer: sizeReport,
        }),
        
        // create loadable-stats.json when server side rendering is enabled
        ...(extend.serverSideRendering ? [
          new LoadablePlugin({
            filename: '../loadable-stats.json',
            writeToDisk: true,
          }),
        ] : []),
        
        // create html files
        ...(extend.templateFiles.length > 0 ? extend.templateFiles.map(templateFile => {
          const extname: string = path.extname(templateFile);
          const filename: string = path.basename(templateFile, extname);
          
          return new HtmlWebpackPlugin({
            template: path.join(cwd, 'src', app, templateFile),
            filename: filename + '.html',
          });
        }) : []),
      ],
github frontity / frontity / packages / core / src / config / webpack / plugins.ts View on Github external
target !== "server" ? `../` : ""
      }analyze/${target}-${mode}.html`,
      openAnalyzer: false,
      logLevel: "silent"
    }),
    new WatchIgnorePlugin([new RegExp(outDir)])
  ];

  // Support HMR in development. Only needed in client.
  if (target !== "server" && mode === "development")
    config.push(new HotModuleReplacementPlugin());

  // Needed for code splitting in client.
  if (target !== "server")
    config.push(
      new LoadablePlugin({
        filename: `../bundling/chunks.${target}.json`
      })
    );

  // Avoid code splitting in server.
  if (target === "server")
    config.push(new optimize.LimitChunkCountPlugin({ maxChunks: 1 }));
  return config;
};
github osamu38 / react-ssr-starter / tools / webpack / getServerPlugins.js View on Github external
export default function getPlugins(isAnalyze) {
  return [
    new webpack.IgnorePlugin(/webpack\.client\.babel/),
    new webpack.EnvironmentPlugin({ NODE_ENV: `${env}` }),
    new CleanWebpackPlugin([joinPath('dist/server.js')], {
      root: joinPath(),
    }),
    new webpack.optimize.LimitChunkCountPlugin({ maxChunks: 1 }),
    new LoadablePlugin(),
    ...(isAnalyze ? [new BundleAnalyzerPlugin({ analyzerPort: 8889 })] : []),
  ];
}
github smooth-code / smooth.js / packages / smooth / src / config / webpack.js View on Github external
'graphql/execution',
            'graphql/validation',
          ]
        : undefined,
    output: {
      path: path.join(config.cachePath, target, 'static'),
      filename: dev ? '[name].js' : '[name]-bundle-[chunkhash:8].js',
      publicPath: `/web/static/`,
      libraryTarget: target === 'node' ? 'commonjs2' : undefined,
    },
    plugins: [
      new webpack.EnvironmentPlugin({
        __smooth_blocks: blocksPath,
        __smooth_pages: config.pagesPath,
      }),
      new LoadablePlugin(),
      ...(target === 'node' && dev ? [new SmoothCacheHotReloader()] : []),
      ...(target === 'web' && dev
        ? [new webpack.HotModuleReplacementPlugin()]
        : []),
    ],
  }

  const webpackConfig = onCreateWebpackConfig(config)({
    stage: getStage({ target, dev }),
    webpackConfig: defaultWebpackConfig,
  })

  return config.webpack(webpackConfig, options)
}
github osamu38 / react-ssr-starter / tools / webpack / getClientPlugins.js View on Github external
export default function getPlugins(isAnalyze) {
  return [
    new webpack.EnvironmentPlugin({
      NODE_ENV: `${env}`,
      ...(process.env.HEROKU_DOMAIN
        ? { HEROKU_DOMAIN: process.env.HEROKU_DOMAIN }
        : {}),
    }),
    new webpack.NoEmitOnErrorsPlugin(),
    new LoadablePlugin(),
    ...(isDevelopment
      ? [
          new webpack.NamedModulesPlugin(),
          new webpack.HotModuleReplacementPlugin(),
          new FriendlyErrorsWebpackPlugin(),
        ]
      : [
          new CleanWebpackPlugin([joinPath('dist')], {
            root: joinPath(),
            exclude: ['server.js'],
          }),
          new CopyWebpackPlugin([
            {
              from: './public',
              to: joinPath('dist/public'),
              ignore: ['.DS_Store'],

@loadable/webpack-plugin

Webpack plugin for loadable (required for SSR).

MIT
Latest version published 3 years ago

Package Health Score

73 / 100
Full package analysis

Popular @loadable/webpack-plugin functions