Webpack with multiple angular 2 modules

I have an ASP.NET Core site with 2 pages, page routing is done through MVC , not Angular 2 . Each of these pages has its own Angular 2 application. It is very difficult for me to try to get this to work with webpack .

If I load both components into one module, I get the error The selector "xxx" did not match any elements . However, if I try to create multiple webpack.config.js in webpack.config.js , then the polyfills will exit because it cannot find another module.

How do I make this work? The only option available to me here is to force the use of an Angular 2 router and create a SPA?

Here is the relevant part of my webpack.config.js :

 entry: { "polyfills": "./App/polyfills.ts", "vendor": "./App/vendor.ts", "firstapp": "./App/bootfirst.ts", "secondapp": "./App/bootsecond.ts" }, resolve: { extensions: ['', '.ts', '.js', '.json', '.css', '.scss', '.html'] }, output: { path: process.cwd() + "/wwwroot", publicPath: "/js/", filename: "js/[name].js" }, 
+6
source share
1 answer

Unfortunately, I had to use this atrocity to keep going. Please help me find the right solution.

 entry: { "polyfills": "./App/polyfills.ts", "vendor": "./App/vendor.ts", "app": "./App/bootfirst.ts" //"app": "./App/bootsecond.ts" }, resolve: { extensions: ['', '.ts', '.js', '.json', '.css', '.scss', '.html'] }, output: { path: process.cwd() + "/wwwroot", publicPath: "/js/", filename: "js/[name].first.js" //filename: "js/[name].second.js" }, 
+1
source

Source: https://habr.com/ru/post/1013644/


All Articles