Different webpack loaders for different js records

Is it possible to load an additional entry using a different set of bootloaders?

For example, I'm trying to create a service for offline caching. I deleted the folder containing the service worker and included it in another. There are no calls for service-worker.js (it just loads manually in static index.html). The service worker's entry point collects React and hot loader instead of just going through Babel. Here are the main parts of my configuration.

entry: { app: "app.js", 'service-worker': 'persistence/service-worker.js' }, module: { loaders:[{ test: /\.js|\.jsx/, loaders: ["react-hot", "jsx?harmony", "babel"], exclude: /persistence/ }, { test: /service\-worker\.js/, loaders: ["babel"], include: /persistence/ }] 
+7
webpack
source share
1 answer

I decided to use a file loader (with babel to pre-process js files). It works in hot boot mode as well as in my Docker / Node work environment.

 loaders: { { test: /\.(js|jsx)$/, include: [/src/,/bower_components/], exclude: [/persistence/], loader: 'jsx?harmony!babel' }, { test: /\.js$/, include: [/persistence/], loader: 'file?name=[name].[ext]!babel' }, ... }, 

This configuration excludes the folder from regular JS files and separately copies the Service Worker files to the root directory of the site.

0
source share

All Articles