insin / nwb

A toolkit for React, Preact, Inferno & vanilla JS apps, React libraries and other npm modules for the web, with no configuration (until you need it)
Other
5.57k stars 331 forks source link

setting webpack.extra.entry seems to break hot-reloading #105

Closed brumm closed 7 years ago

brumm commented 8 years ago

I set up a new project today, which involves a somewhat complicated nwb.config.js (pasted in full below).

Unfortunately, I seem to have broken HMR in the process, there's no [HMR] log output in the console, and the app does not react to file changes.

Renaming the renderer folder back to src and removing the option for webpack.extra.entry seems to fix things, but I'd like to be able to rename the src if possible.

const path = require('path');
const webpack = require('webpack');
const package = require('./package.json');
const ComponentResolverPlugin = require('component-resolver-webpack');

const cssConfig = {
  query: {
    modules: true,
    localIdentName: '[local]-[hash:base64:10]'
  }
}

module.exports = {
  type: 'react-app',

  webpack: {
    extra: {
      entry: path.resolve('./renderer/index.js'),
      resolve: {
        root: [path.resolve('./renderer')],
        extensions: ["", ".webpack.js", ".web.js", ".js", ".scss"]
      },
      plugins: [
        new webpack.ResolverPlugin([
          new ComponentResolverPlugin()
        ])
      ],
      output: {
        publicPath: ''
      }
    },
    loaders: {
      'css': cssConfig,
      'sass-css': cssConfig
    },
    plugins: {
      html: {
        template: path.resolve('./renderer/index.html'),
        title: package.name
      }
    }
  },

  babel: {
    stage: 0
  }
}
insin commented 8 years ago

There are a number of places where src/ and src/index.js are hardcoded, so just using extra probably isn't enough for now.

Will look into making this properly configurable.

insin commented 7 years ago

Closing in favour of #115 for tracking making this configurable - thanks for the example real-world config, will come in useful when testing the feature.