Search code examples
angular-cli-v6

--dev option not working in Angular CLI


Recently I upgraded to Angular CLI 6.0.3. My previous build script was

"build": "ng build --output-path ../public/ui", which worked fine and generated files

/ui/inline.bundle.js”. /ui/polyfills.bundle.js”. /ui/vendor.bundle.js”. /ui/styles.bundle.js”. /ui/main.bundle.js”

I notice that after upgrade, the files been generated have different names

main.js polyfills.js runtime.js styles.js vendor.js

I thought that maybe the default build is prod so I changed my script to "build": "ng build --dev --output-path ../public/ui",

but I get error Unknown option: '--dev'

What am I doing wrong? Have the generated file name changed in v6?


Solution

  • Yes they have changed the names of the generated bundles.

    Angular cli v 1.7

    node_modules/@angular/cli/models/webpack-configs/common.js

    output: {
            path: path.resolve(buildOptions.outputPath),
            publicPath: buildOptions.deployUrl,
            filename: `[name]${hashFormat.chunk}.bundle.js`,
            chunkFilename: `[id]${hashFormat.chunk}.chunk.js`
        }
    

    Angular cli v6

    node_modules/@angular-devkit/build-angular/src/angular-cli-files/models/webpack-configs/common.js

    output: {
            path: path.resolve(root, buildOptions.outputPath),
            publicPath: buildOptions.deployUrl,
            filename: `[name]${hashFormat.chunk}.js`,
        },
    

    And dev is the default mode when using ng build AFAIK