Nwb: index.jsx

Created on 2 Jul 2017  路  3Comments  路  Source: insin/nwb

This issue is a: Feature request

Could you let us use index.jsx instead of index.js for react components???

enhancement

Most helpful comment

@insin I would go a bit further than that and make the default entry point just 'src/index'.

Why? Simple - we use nwb in TypeScript environment, and have an src/index.tsx. I envision someone could have src/index.ts instead, and hardcoding all of that just doesn't make any sense. Maybe at some point people will start embracing esm extension. Just let webpack handle it, hardcoded extensions make it harder.

All 3 comments

@insin I would go a bit further than that and make the default entry point just 'src/index'.

Why? Simple - we use nwb in TypeScript environment, and have an src/index.tsx. I envision someone could have src/index.ts instead, and hardcoding all of that just doesn't make any sense. Maybe at some point people will start embracing esm extension. Just let webpack handle it, hardcoded extensions make it harder.

Any update on this? I would like to use the extension .jsx for all React components but I want to avoid have to override the webpack rules and resolve configuration.

Update - change of plans
In case someone else wants to do the same, the config below can save you a couple of minutes.

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

module.exports = {
  type: 'react-app',
  webpack: {
    rules: {
      babel: {
        test: /\.jsx?/,
      },
    },
    extra: {
      entry: resolve(__dirname, 'src'),
      resolve: {
        extensions: ['.js', '.jsx'],
      },
    },
  },
};

Update - change of plans
In case someone else wants to do the same, the config below can save you a couple of minutes.

thanks a lot!!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tbillington picture tbillington  路  6Comments

lachlanjc picture lachlanjc  路  3Comments

sergiop picture sergiop  路  5Comments

insin picture insin  路  3Comments

tlindsay picture tlindsay  路  3Comments