如何利用webpack的角度动态现场?
在运行时,当执行"tmhDynamicLocale.set('de');“时,角动态区域设置总是尝试从路径tmhDynamicLocale.set加载角-locale_en.js文件。
因此,我使用webpack定义了每个依赖项,无论是在我的app.js顶部还是在我的控制器顶部。我试图用require(‘angt-i18n/angular_de’)或import (但不幸的是,我总是收到以下错误消息)来定义它:
GET http://localhost:8080/angular/i18n/angular-locale_de.js net::ERR_ABORTED 404 (Not Found)
Refused to execute script from 'http://localhost:8080/angular/i18n/angular-locale_de.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.发布于 2018-10-18 15:56:25
如果你像这样使用你的地点:
tmhDynamicLocaleProvider
.localeLocationPattern('./angular/i18n/angular-locale_{{locale}}.js')
.defaultLocale('de');您可能可以像这样使用CopyWebpackPlugin:
new CopyWebpackPlugin([
{from: './node_modules/angular-i18n/angular-locale_de.js', to: path.resolve(__dirname, '.[WEBPACK OUTPUT FOLDER]' + '/angular/i18n')}
])确保目标文件夹与the打包文件的输出相匹配。
https://stackoverflow.com/questions/52877213
复制相似问题