我正在尝试设置我的 vite 构建,以便它输出一个带有预定义名称的 js 文件。这是我的vite.config.js:
build: {
lib: {
entry: resolve(__dirname, "src/scripts/foo.ts"),
name: "foo",
formats: ["es"],
},
rollupOptions: {
output: {
file: "foo",
inlineDynamicImports: true,
format: "es",
},
},
}
Run Code Online (Sandbox Code Playgroud)
此配置会产生错误消息:Invalid value for option "output.dir" - you must set either "output.file" for a single-file build or "output.dir" when generating multiple chunks.
但是如果我设置该rollupOptions.output.dir选项 - 将创建一个 JS 文件(因此不会有多个块)。
我想在我的文件夹中生成一个 js 文件dist,其中包含所有依赖项,并具有预定义的名称。有什么配置可以让我这样做吗?
我正在尝试重新创建一个非常类似于ngrx文档的authEffect,并收到此错误消息:
Error: StaticInjectorError(AppModule)[HttpClient -> HttpHandler]:
StaticInjectorError(Platform: core)[HttpClient -> HttpHandler]:
NullInjectorError: No provider for HttpHandler!
效果服务:
@Injectable()
export class HttpEffects {
constructor(private http: HttpClient, private actions$: Actions) {}
@Effect() login$: Observable<ActionWithPayload> = this.actions$.pipe(
ofType(ActionTypes.SEND_LOGIN),
mergeMap((action: ActionWithPayload) =>
this.http.post(SERVER_URL + LOGINAPI.LOGIN, action.payload, config).pipe(
map(data => ({type: 'LOGIN_SUCCESS', payload: data})),
catchError(() => of({type: 'LOGIN_ERROR'}))
))
);
}
Run Code Online (Sandbox Code Playgroud)
app.module:
@NgModule({
declarations: [
AppComponent,
],
imports: [
BrowserModule,
BrowserAnimationsModule,
StoreModule.forRoot(rootReducer),
StoreDevtoolsModule.instrument({
maxAge: 10
}),
EffectsModule.forRoot([HttpEffects])
],
exports: [
BrowserAnimationsModule
],
providers: …Run Code Online (Sandbox Code Playgroud)