0

I want to add one of my file (module) in externals. So that we can skip that file and its dependecies.

For that I saw this: Exclude module from webpack minification

According to that I tried this:

  externals: {
    "./Hello.js": path.resolve(__dirname, "./src/client/Hello.js")
  },

Home.js

import Hello from './Hello.js';
 //content
export default class Home

App.js

const LoadingComponent = () => <h1>loading Please wait</h1>

const Home = loadable({
  loader: () => import(/* webpackChunkName: 'Homepage' */'./Home.js'),
  loading: LoadingComponent
})

index.html

    <script type="text/javascript" src="bundle.js"></script>
    <script type="text/javascript" src="custom-file.js"></script>

where custom-file.js contain the hello.js content

But when I open the home page. Only loadable's loading part is shown that is

<h1>loading Please wait</h1>

On chrome source tab, I am getting this in Home.js

/* harmony import */ var _Hello_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Hello.js */ "./Hello.js");
/* harmony import */ var _Hello_js__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_Hello_js__WEBPACK_IMPORTED_MODULE_2__);

If it becomes __webpack_require__(/*! ./Hello.js */ "./src/client/Hello.js");. then I think it would work fine

bjhbj
  • 1
  • 1

0 Answers0