question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Enhancement Request] Angular compiler settings

See original GitHub issue

Hi Jeffrey,

In its current state, it’s not possible to run laravel mix for Angular in production mode without breaking the Angular. I do understand that Laravel is preferring Vue over Angular, but given the market share for Angular, I’d like to request to add ng-angular-annotations into the package as well.

I’ve tried to use the ng-angular-loader and add it to the config with webpackConfig but for some reason the loader doesn’t properly annotate.

The only solution that I found is to use the ng-annotate-webpack-plugin. Unfortunately, I have to use a custom webpack.config.js to add this package, as I couldn’t include the package via the merge command.

Here’s the current custom code that I’m adding:

let ngAnnotatePlugin = require('ng-annotate-webpack-plugin');

module.exports = {
    plugins: [
        new ngAnnotatePlugin({
            add: true
        })
    ]
};

Sorry if I overlooked an easier solution. I’m still fairly new to webpack2 - and thank you for your time!

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
oli-labancommented, Dec 21, 2017

My solution to this was to use babel-loader

mix.webpackConfig({
    module: {
	rules: [
	    {
		test: /\.js$/,
	        loader: ['babel-loader']
	    }
        ]
    }
});

with babel-plugin-angularjs-annotate

{
    "presets": [
        "es2015"
    ],
    "plugins": [
        "angularjs-annotate"
    ]
}

uglifyjs-webpack-plugin causes ng-annotate-webpack-plugin to break and ng-annotate-loader won’t work if you use arrow functions, but the babel way works great for me.

1reaction
mateopcommented, Mar 1, 2017

ngAnnotate works fine for me like this:

mix.js('resources/assets/js/app.js', 'public/js')
    .webpackConfig({
        module: {
            rules: [
                {test: /\.js$/, loader: ['ng-annotate-loader']}
            ]
        }
    })
Read more comments on GitHub >

github_iconTop Results From Across the Web

[Enhancement Request] Angular compiler settings · Issue #470
I've tried to use the ng-angular-loader and add it to the config with webpackConfig but for some reason the loader doesn't properly annotate....
Read more >
Angular compiler options
Instructs the Angular template compiler to create legacy ids for messages that are tagged in templates by the i18n attribute. See Mark text...
Read more >
Ahead-of-time (AOT) compilation - Angular
This guide explains how to specify metadata and apply available compiler options to compile your applications efficiently using the AOT compiler.
Read more >
TypeScript configuration - Angular
See the Angular compiler options guide for information about what Angular specific options are available. The TypeScript and Angular have a wide range...
Read more >
How the Angular Compiler Works
The main goal of ngc is to compile TypeScript code while transforming recognized Angular decorated classes into more efficient representations ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found