Can't find index.js when ES 6 app served by django is responsive

I created a reactive app in ES6 and created bundle.js

and linked it in an HTML page served by django. The app worked fine during development on a node server, but when the page is served by django linked to a static file bundle.js

, I got the following error:

VM1517:1 Uncaught Error: Cannot find module "./src/index.js"

      

please note what index.js

is the entry point of this app-app. any help is appreciated! thank!

webpack.config.js

below:

module.exports = {
  entry: [
    './src/index.js'
  ],
  output: {
    path: __dirname,
    publicPath: '/',
    filename: 'bundle.js'
  },
  module: {
    loaders: [{
      exclude: /node_modules/,
      loader: 'babel'
    }]
  },
  resolve: {
    extensions: ['', '.js', '.jsx']
  },
  devServer: {
    contentBase: './'
  }
};

      

UPDATE: @kaylus webpack output below:

ERROR in ./src/index.js
Module build failed: SyntaxError: Unexpected token (137:12)

  135 |     render() {
  136 |         return (
> 137 |             <div className='container'>

      

UPDATE: I resolved this issue by referring @Kaylus link to this post on this stackoverflow post .

+3


source to share


1 answer


Make sure you have your .babelrc with at least es2015 and react like presets. Also, and I may be reading this wrong, but if your output filename is "bundle.js" why are you trying to serve "index.js"?

UPDATE:



Nevermind, I read this wrong. Add publicPath to your devServer.

+1


source







All Articles