Google Chrome extension using Angular CLI stuck in boot

I am trying to develop a simple Google Chrome extension using the angular CLI, but it is stuck on Loading.

enter image description here

If I try to run the application using npm startand opening it in a browser window, it works fine.

enter image description here

I am also trying to compile my application with ng build, put mine manifest.jsonin my folder dist, but the result will be the same.

my manifest.json :

{
  "manifest_version": 2,

  "name": "Weather for Chrome",
  "description": "Weather for Chrome is a simple Google chrome plugin using angular CLI",
  "version": "1.0",

  "browser_action": {
    "default_icon": "assets/Soleil.png",
    "default_popup": "index.html"
  },
  "permissions": [
    "activeTab",
    "https://ajax.googleapis.com/"
  ]
}

app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { AppRoutingModule } from './app-routing.module';

import { AppComponent } from './app.component';
import { WeatherService } from "./_services/weather.service";
import { PopupComponent } from "./popup/popup.component";

@NgModule({
  declarations: [
    AppComponent,
    PopupComponent
  ],
  imports: [
    BrowserModule,
    FormsModule,
    HttpModule,
    AppRoutingModule
  ],
  providers: [
    WeatherService
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }

app.component.ts

import { Component } from '@angular/core';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.sass']
})
export class AppComponent {
  title = 'app works!';
}

app-routing.module.ts

import { Component } from '@angular/core';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.sass']
})
export class AppComponent {
  title = 'app works!';
}

I don't know how to debug a chrome extension. Thanks for answers.

+4
source share
1 answer

angular 2 @angular/cli. , , , .. Refused to evaluate a string as JavaScript because 'unsafe-eval'.

, Inspect Popup. : Chrome

. manifest.json /dist, . :

{
  "manifest_version": 2,

  "name": "Extension",
  "description": "This extension ...",
  "version": "1.0",

  "browser_action": {
    "default_icon": "icon.png",
    "default_popup": "index.html"
  },
  "permissions": [
    "activeTab",
    "https://ajax.googleapis.com/"
  ],

  "content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'"
}
+3

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


All Articles