angular / ngMigration-Forum

109 stars 7 forks source link

Migration using webpack #8

Open ochampet opened 5 years ago

ochampet commented 5 years ago

I have a large application the assistant told me several need to be modified. Try the hybrid approach of moving it as app-ajs does not let me get to compile

Is there a way in which the packages build by my current webpack process can be included as scripts and directly?

Do you see issues with the following? Generate app bundle and vendor bundle .js import he bundle.js use existing static files

This plan would bring all existing js/ts code without the need to compile them inside the application

Has anybody done something similar?

pankaj28843 commented 5 years ago

@ochampet I also have similar situation. We already have a sophisticated webpack setup which does many things.

I came across @angular-builders/custom-webpack and have been able to run dev server and build using @angular/cli. Most difficult part was trying to figure out correct override option.

Finally I could get it to work with below options for build part of angular.json config file:

"build": {
    "builder": "@angular-builders/custom-webpack:browser",
    "options": {
    "customWebpackConfig": {
        "path": "./webpack.config.js",
        "mergeStrategies": {
        "module.rules": "replace",
        "plugins": "replace"
        },
        "replaceDuplicatePlugins": true
    },
    // rest of the confg follows
}

You can find more about webpack merge at: https://github.com/survivejs/webpack-merge

I've only a week's effort on migration using @angular/hybrid. I'm playing around different options, trying to evaluate difficulties of various approaches.