Sha256: e17716bcb78164438435259fee6b6cdf2fe3ae6b047bd035145ca5e7131c528b

Contents?: true

Size: 1.88 KB

Versions: 3

Compression:

Stored size: 1.88 KB

Contents

// For inspiration on your webpack configuration, see:
// https://github.com/shakacode/react_on_rails/tree/master/spec/dummy/client
// https://github.com/shakacode/react-webpack-rails-tutorial/tree/master/client

const webpack = require('webpack');
const { resolve } = require('path');

const ManifestPlugin = require('webpack-manifest-plugin');
const webpackConfigLoader = require('react-on-rails/webpackConfigLoader');

const configPath = resolve('..', 'config');
const { devBuild, output } = webpackConfigLoader(configPath);

const config = {

  context: resolve(__dirname),

  entry: {
    'hello-world-bundle': [
      'es5-shim/es5-shim',
      'es5-shim/es5-sham',
      'babel-polyfill',
      './app/bundles/HelloWorld/startup/registration',
    ],
  },

  output: {
    // Name comes from the entry section.
    filename: '[name]-[chunkhash].js',

    // Leading slash is necessary
    publicPath: `/${output.publicPath}`,
    path: output.path,
  },

  resolve: {
    extensions: ['.js', '.jsx'],
  },

  plugins: [
    new webpack.EnvironmentPlugin({
      NODE_ENV: 'development', // use 'development' unless process.env.NODE_ENV is defined
      DEBUG: false,
    }),
    new ManifestPlugin({
      publicPath: output.publicPath,
      writeToFileEmit: true }),
  ],

  module: {
    rules: [
      {
        test: require.resolve('react'),
        use: {
          loader: 'imports-loader',
          options: {
            shim: 'es5-shim/es5-shim',
            sham: 'es5-shim/es5-sham',
          },
        },
      },
      {
        test: /\.jsx?$/,
        use: 'babel-loader',
        exclude: /node_modules/,
      },
    ],
  },
};

module.exports = config;

if (devBuild) {
  console.log('Webpack dev build for Rails'); // eslint-disable-line no-console
  module.exports.devtool = 'eval-source-map';
} else {
  console.log('Webpack production build for Rails'); // eslint-disable-line no-console
}

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
react_on_rails-9.0.0.beta.11 lib/generators/react_on_rails/templates/base/base/client/webpack.config.js
react_on_rails-9.0.0.beta.10 lib/generators/react_on_rails/templates/base/base/client/webpack.config.js
react_on_rails-9.0.0.beta.9 lib/generators/react_on_rails/templates/base/base/client/webpack.config.js