Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including razzle-plugin-device-specific-bundles with all npm packages installed. Try it out:

var razzlePluginDeviceSpecificBundles = require("razzle-plugin-device-specific-bundles")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

razzle-plugin-device-specific-bundles v1.0.1

Plugin for creating device specific bundles with Razzle.

razzle-plugin-device-specific-bundles

This package contains a plugin for creating device specific with Razzle.

See the example.

Usage in Razzle Projects

yarn add --dev razzle-plugin-device-specific-bundles

Using the plugin with the default options

// razzle.config.js

module.exports = {
  plugins: ['device-specific-bundles'],
};

With custom options:

// razzle.config.js

module.exports = {
  plugins: [
    {
      name: 'device-specific-bundles',
      options: {
        devices: ['desktop', 'mobile'],
        entry: 'ssr.js',
        alias: 'SSR'
      },
    },
  ],
};

Options

devices: array (defaults: ['desktop', 'mobile'])

An array with all the enabled devices

entry: string (defaults: ssr.js)

Entry point (relative to the src folder) of the server side rendering function file.

alias: string (defaults: SSR)

Alias used to include in the server (src/index.js) entry point the device specific server side rendering functions.

Considerations

Razzle comes with a react-dev-utils version that doesn't support webpack's multicompiler output, a newer version must be loaded using the selective version resolutions.

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free