如何从角构建中排除弯矩区域?

编程入门 行业动态 更新时间:2024-10-23 19:26:03
本文介绍了如何从角构建中排除弯矩区域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在我的angular 5应用程序中,当我使用

In my angular 5 application, when I create build using

ng build --prod --sm

和开放源代码地图浏览器,此刻在main.js文件中占用了大量空间.我发现使用时会加载所有语言环境

and open source map explorer, moment takes lot of space in the main.js file. I have found all the locales gets loaded when I use

import * as moment from 'moment';

我在需要瞬间打包的应用程序中使用了material-moment-adapter来实现某些功能.

I have used material-moment-adapter to some functionality in the application that requires the moment package also.

我已经使用angular-cli创建了该应用程序.我发现使用webpack.config.js中的设置排除了语言环境的许多链接有什么方法可以使用angular-cli排除语言环境?

I have created the application using angular-cli. I have found many links that excludes locales using settings in webpack.config.js Is there any way to exclude locales using angular-cli ?

推荐答案

本文介绍了很好的解决方案: medium.jonasbandi/angular-cli-and-moment-js-a-recipe-for-disaster-and-how-to-fix-it-163a79180173

This article describe good solution: medium.jonasbandi/angular-cli-and-moment-js-a-recipe-for-disaster-and-how-to-fix-it-163a79180173

简而言之:

  • ng添加ngx-build-plus

    在项目的根目录中添加文件webpack.extra.js:

    Add a file webpack.extra.js in the root of your project:

    const webpack = require('webpack'); module.exports = { plugins: [ new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/), ] }

  • 运行:

  • Run:

    npm run build --prod --extra-webpack-config webpack.extra.js

    在此处输入代码

    警告moment.js已被正式弃用 momentjs/docs/#/-project-status/(尝试使用day.js或luxon)

    Warning moment.js has been deprecated officially momentjs/docs/#/-project-status/ (try use day.js or luxon)

  • 更多推荐

    如何从角构建中排除弯矩区域?

    本文发布于:2023-11-16 17:01:21,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1606168.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:弯矩   区域

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!