How to use the webpack.PrefetchPlugin function in webpack

To help you get started, we’ve selected a few webpack 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 jedwards1211 / meteor-webpack-react / webpack / make-webpack-config.js View on Github external
},
      module: {
        loaders: [
          {
            test: /\.css$/,
            loader: 'style-loader!css-loader'
          },
          { test: /\.json$/, loader: 'json-loader' }
        ]
      },
      plugins: [
        new webpack.DefinePlugin({
          'Meteor.isClient': true,
          'Meteor.isServer': false
        }),
        new webpack.PrefetchPlugin("react"),
        new webpack.PrefetchPlugin("react/lib/ReactComponentBrowserEnvironment")
      ]
    });

    ////////////////////////////////////////////////////////////////////////////////
    // CLIENT DEVELOPMENT
    ////////////////////////////////////////////////////////////////////////////////

    if (mode === 'dev') {
      config = merge.smart({
        entry: [
          'webpack-dev-server/client?' + baseUrl,
          'webpack/hot/only-dev-server'
        ],
        plugins: [
          new webpack.HotModuleReplacementPlugin(),
github jaysoo / todomvc-redux-react-typescript / webpack / make-webpack-config.js View on Github external
"ts|tsx": {
      loaders: ['react-hot', 'ts-loader']
    }
  };

  var stylesheetLoaders = {
    "css": 'css-loader'
  };

  var publicPath = options.development
    ? "http://localhost:2992/_assets/"
    : "/_assets/";
  
  if (options.development) {
    var plugins = [
      new webpack.PrefetchPlugin("react"),
      {
        apply: function (compiler) {
          compiler.plugin('after-emit', function (compilation, done) {
            var stats = compilation.getStats().toJson({
              // node_modules/webpack/lib/Stats.js
              hash: true,
              version: true,
              timings: false,
              assets: true,
              chunks: false,
              chunkModules: false,
              chunkOrigins: false,
              modules: false,
              cached: false,
              reasons: false,
              children: false,
github darul75 / personal-blog / conf / webpack-config.js View on Github external
let suffix = '',
      outputPath = path.join(root_dir, 'build');

  let processVars = {
    'process.env':{}
  };

  // PRODUCTION CASE
  if (prod) {
    // WRAP INTO CSS FILE
    cssLoaders = extractForProduction(cssLoaders);
    sassLoaders = extractForProduction(sassLoaders);
    scssLoaders = extractForProduction(scssLoaders);

    suffix = '-prod';
    plugins.push(new webpack.PrefetchPlugin("react"));
    plugins.push(new ExtractTextPlugin("app-[hash].css"));
    processVars['process.env'].NODE_ENV = JSON.stringify('production');

    outputPath = path.join(root_dir, 'dist');
  }

  // HTML TEMPLATE + ENV VARIABLE
  if (client) {
    suffix = !devserver ? suffix : '-dev';
    processVars['process.env'].BROWSER = JSON.stringify(true);
    plugins.push(new Clean(cleanDirectories, root_dir));
    plugins.push(new webpack.DefinePlugin(processVars));
    plugins.push(new webpack.optimize.CommonsChunkPlugin('vendors', 'vendors.js'));
    plugins.push(new webpack.optimize.DedupePlugin());
    plugins.push(new webpack.optimize.OccurenceOrderPlugin(true));
    if (prod) {
github jedwards1211 / meteor-webpack-react / webpack / webpack.config.client.js View on Github external
module: {
    loaders: [
      {
        test: /\.jsx?$/,
        loader: 'babel?stage=0',
        exclude: /node_modules|react-runtime\.js/,
      }, 
      {
        test: /\.css$/,
        loader: 'style-loader!css-loader'
      }, 
    ],
  },
  plugins: [
    new webpack.PrefetchPlugin("react/addons"),
    new webpack.PrefetchPlugin("react"),
    new webpack.PrefetchPlugin("react/lib/ReactComponentBrowserEnvironment"),
    new webpack.optimize.CommonsChunkPlugin('react', 'react.bundle.js'),
  ]
};
github jedwards1211 / meteor-webpack-react / webpack / webpack.config.client.js View on Github external
loaders: [
      {
        test: /\.jsx?$/,
        loader: 'babel?stage=0',
        exclude: /node_modules|react-runtime\.js/,
      }, 
      {
        test: /\.css$/,
        loader: 'style-loader!css-loader'
      }, 
    ],
  },
  plugins: [
    new webpack.PrefetchPlugin("react/addons"),
    new webpack.PrefetchPlugin("react"),
    new webpack.PrefetchPlugin("react/lib/ReactComponentBrowserEnvironment"),
    new webpack.optimize.CommonsChunkPlugin('react', 'react.bundle.js'),
  ]
};
github webpack / react-starter / make-webpack-config.js View on Github external
"/_assets/";
	var output = {
		path: path.join(__dirname, "build", options.prerender ? "prerender" : "public"),
		publicPath: publicPath,
		filename: "[name].js" + (options.longTermCaching && !options.prerender ? "?[chunkhash]" : ""),
		chunkFilename: (options.devServer ? "[id].js" : "[name].js") + (options.longTermCaching && !options.prerender ? "?[chunkhash]" : ""),
		sourceMapFilename: "debugging/[file].map",
		libraryTarget: options.prerender ? "commonjs2" : undefined,
		pathinfo: options.debug || options.prerender
	};
	var excludeFromStats = [
		/node_modules[\\\/]react(-router)?[\\\/]/,
		/node_modules[\\\/]items-store[\\\/]/
	];
	var plugins = [
		new webpack.PrefetchPlugin("react"),
		new webpack.PrefetchPlugin("react/lib/ReactComponentBrowserEnvironment")
	];
	if(options.prerender) {
		plugins.push(new StatsPlugin(path.join(__dirname, "build", "stats.prerender.json"), {
			chunkModules: true,
			exclude: excludeFromStats
		}));
		aliasLoader["react-proxy$"] = "react-proxy/unavailable";
		aliasLoader["react-proxy-loader$"] = "react-proxy-loader/unavailable";
		externals.push(
			/^react(\/.*)?$/,
			/^reflux(\/.*)?$/,
			"superagent",
			"async"
		);
		plugins.push(new webpack.optimize.LimitChunkCountPlugin({ maxChunks: 1 }));
github molgenis / molgenis / molgenis-core-ui / src / main / frontend / webpack.production.config.js View on Github external
'utils' : 'modules/utils'
        }
    },
    context: __dirname,
    entry: {
        'global-ui': ['molgenis-global-ui-webpack'],
        'global': ['molgenis-global-webpack'],
        'vendor-bundle': ['molgenis-vendor-webpack']
    },
    output: {
        path : '../../../target/classes/js/dist',
        filename: 'molgenis-[name].js',
        publicPath: '/js/dist/'
    },    
    plugins: [
        new webpack.PrefetchPlugin('react/lib/ReactWithAddons'),
        new webpack.PrefetchPlugin('react/lib/DOMChildrenOperations.js'),
        new webpack.PrefetchPlugin('react/lib/ReactDOMComponent'),
        new webpack.PrefetchPlugin('react/lib/ReactReconcileTransaction'),
        new webpack.PrefetchPlugin('react/lib/React'),
        new webpack.PrefetchPlugin('react-components'),
        new webpack.PrefetchPlugin('moment'),
        new webpack.PrefetchPlugin('promise'),
        new webpack.PrefetchPlugin('./src/modules/react-components/wrapper/JQRangeSlider.js'),
        new webpack.ProvidePlugin({$: "jquery", jQuery: "jquery"}),
        new webpack.optimize.OccurenceOrderPlugin(),
        new webpack.DefinePlugin({
        	'process.env': {
            	'NODE_ENV': '"production"'
            }
        }),
        new webpack.optimize.UglifyJsPlugin({
github reverentgeek / reactor / webpack / make-webpack-config.js View on Github external
: "/dist/";

	var output = {
		path: projectRoot + "/dist/",
		filename: "bundle.js",
		publicPath: publicPath,
		contentBase: projectRoot + "/public/",
		libraryTarget: "commonjs2"
	};

	var excludeFromStats = [
	/node_modules[\\\/]react(-router)?[\\\/]/
	];

	var plugins = [
	new webpack.PrefetchPlugin( "react" ),
	new webpack.PrefetchPlugin( "react/lib/ReactComponentBrowserEnvironment" ),
	new webpack.ProvidePlugin( { $: "jquery", jQuery: "jquery" } )
	];

	if ( opts.prerender ) {
		plugins.push( new StatsPlugin( path.join( projectRoot, "dist", "stats.prerender.json" ), {
			chunkModules: true,
			exclude: excludeFromStats
		} ) );
		aliasLoader["react-proxy$"] = "react-proxy/unavailable";
		aliasLoader["react-proxy-loader$"] = "react-proxy-loader/unavailable";
		externals.push(
		/^react(\/.*)?$/,
		/^reflux(\/.*)?$/,
		"superagent",
		"async"
github skevy / graphiql-app / webpack / make-webpack-config.js View on Github external
var output = {
    path: projectRoot + '/dist/',
    filename: 'bundle.js',
    publicPath: publicPath,
    contentBase: projectRoot + '/public/',
    libraryTarget: 'commonjs2'
  };

  var excludeFromStats = [
    /node_modules[\\\/]react(-router)?[\\\/]/
  ];


  var plugins = [
    new webpack.PrefetchPlugin('react'),
    new webpack.PrefetchPlugin('react-dom/lib/ReactComponentBrowserEnvironment')
  ];

  if (opts.prerender) {
    plugins.push(new StatsPlugin(path.join(projectRoot, 'dist', 'stats.prerender.json'), {
      chunkModules: true,
      exclude: excludeFromStats
    }));
    aliasLoader['react-proxy$'] = 'react-proxy/unavailable';
    aliasLoader['react-proxy-loader$'] = 'react-proxy-loader/unavailable';
    externals.push(
      /^react(\/.*)?$/,
      /^reflux(\/.*)?$/,
      'superagent',
      'async'
    );
    plugins.push(new webpack.optimize.LimitChunkCountPlugin({ maxChunks: 1 }));
github mattkrick / meatier / webpack / webpack.config.server.js View on Github external
const prefetchPlugins = prefetches.map(specifier => new webpack.PrefetchPlugin(specifier));