如何使用Webpack在Angular 6项目中集成i18n提取和语言环境明智的构建?

时间:2018-08-27 14:29:15

标签: javascript typescript webpack internationalization angular6

我正在使用下面的github构建系统

https://github.com/gdi2290/angular-starter

但是在此版本中,i18n集成无法正常工作。请帮助我在html中使用i18n指令进行i18n提取和本地化构建。

我曾尝试使用AngularCompilerPlugin,但未成功。

下面的我的package.josn文件:

{
"name": "",
"version": "1.0.0",
"description": "",
"keywords": [

],
"author": "",
"homepage": "",
"license": "",
"scripts": {
    "build:aot:prod": "npm run clean:dist && npm run clean:aot && cross-env BUILD_AOT=1 SOURCE_MAP=0 npm run webpack -- --config config/webpack.prod.js  --progress --profile --bail",
    "build:aot": "npm run build:aot:prod",
    "build:aot:dev": "cross-env BUILD_AOT=1 npm run build:dev",
    "build:dev": "npm run clean:dist && npm run webpack -- --config config/webpack.dev.js --progress --profile",
    "build:prod": "npm run clean:dist && npm run webpack -- --config config/webpack.prod.js  --progress --profile --bail",
    "build": "npm run build:dev",
    "ci:aot": "cross-env BUILD_E2E=1 npm run lint && npm run test:ci && npm run build:aot && npm run e2e",
    "ci:jit": "cross-env BUILD_E2E=1 npm run lint && npm run test:ci && npm run build:prod && npm run e2e",
    "ci:nobuild": "npm run lint && npm test:ci && npm run e2e",
    "ci:testall": "cross-env BUILD_E2E=1 npm run lint && npm run test:ci && npm run build:prod && npm run e2e && npm run build:aot && npm run e2e",
    "ci:travis": "cross-env BUILD_E2E=1 npm run lint && npm run test:ci && npm run build:aot && npm run e2e:travis",
    "ci": "npm run ci:testall",
    "clean:all": "npm run rimraf -- doc coverage dist compiled webpack-cache",
    "clean:cache": "npm run rimraf -- webpack-cache",
    "clean:aot": "npm run rimraf -- compiled",
    "clean:dist": "npm run rimraf -- dist",
    "clean:install": "npm set progress=false && npm install",
    "clean": "npm cache verify && npm run rimraf -- node_modules doc coverage dist compiled webpack-cache",
    "docs": "npm run typedoc -- --options typedoc.json --exclude '**/*.spec.ts' ./src/",
    "docs:compodoc": "compodoc -p tsconfig.json",
    "docs:compodoc:serve": "compodoc -p tsconfig.json -s",
    "docs:compodoc:serve:watch": "compodoc -p tsconfig.json -s -w",
    "e2e:live": "npm-run-all -p -r server:prod:ci protractor:live",
    "e2e:travis": "npm-run-all -p -r server:prod:ci protractor:delay",
    "e2e": "npm-run-all -p -r server:prod:ci protractor",
    "lint": "npm run tslint \"src/**/*.ts\"",
    "node": "node",
    "postinstall": "npm run webdriver:update",
    "postversion": "git push && git push --tags",
    "preclean:install": "npm run clean",
    "preversion": "npm test",
    "protractor": "protractor",
    "protractor:delay": "sleep 3 && npm run protractor",
    "protractor:live": "protractor --elementExplorer",
    "rimraf": "rimraf",
    "server:dev:hmr": "npm run server:dev -- --hot",
    "server:aot:dev": "cross-env BUILD_AOT=1 npm run server:dev",
    "server:dev": "npm run webpack-dev-server -- --config config/webpack.dev.js --open --progress --profile --watch --content-base src/",
    "server:prod": "http-server dist -c-1 --cors",
    "server:prod:ci": "http-server dist -p 3000 -c-1 --cors",
    "server": "npm run server:dev",
    "start:prod:hmr": "cross-env ANGULAR_CONF_FILE=./config.prod.json npm run server:dev:hmr",
    "start:hmr": "npm run server:dev:hmr",
    "start": "npm run server:dev",
    "start:aot": "npm run server:aot:dev",
    "test": "npm run lint && karma start",
    "test:ci": "karma start --single-run --browsers ChromeTravisCi",
    "tslint": "tslint",
    "typedoc": "typedoc",
    "version": "npm run build",
    "watch:dev:hmr": "npm run watch:dev -- --hot",
    "watch:dev": "npm run build:dev -- --watch",
    "watch:aot:dev": "npm run build:aot:dev -- --watch",
    "watch:prod": "npm run build:prod -- --watch",
    "watch:aot:prod": "npm run build:aot:prod -- --watch",
    "watch:test": "npm run test -- --auto-watch --no-single-run",
    "watch": "npm run watch:dev",
    "webdriver-manager": "node ./node_modules/protractor/bin/webdriver-manager",
    "webdriver:start": "node ./node_modules/protractor/bin/webdriver-manager start",
    "webdriver:update": "node ./node_modules/protractor/bin/webdriver-manager update",
    "webpack-dev-server": "node --max_old_space_size=4096 node_modules/webpack-dev-server/bin/webpack-dev-server.js",
    "webpack": "node --max_old_space_size=4096 node_modules/webpack/bin/webpack.js",
    "extract": "npm run build:aot:dev --env.xi18n"
},
"dependencies": {
    "@agm/core": "^1.0.0-beta.3",
    "@angular/animations": "6.0.5",
    "@angular/common": "6.0.5",
    "@angular/compiler": "6.0.5",
    "@angular/core": "6.0.5",
    "@angular/forms": "6.0.5",
    "@angular/platform-browser": "6.0.5",
    "@angular/platform-browser-dynamic": "6.0.5",
    "@angular/platform-server": "6.0.5",
    "@angular/router": "6.0.5",
    "bootstrap": "^4.1.3",
    "classlist.js": "^1.1.20150312",
    "core-js": "^2.5.5",
    "crypto-js": "^3.1.9-1",
    "http-server": "^0.11.1",
    "ie-shim": "^0.1.0",
    "jquery": "^3.3.1",
    "jquery-slimscroll": "^1.3.8",
    "lodash": "^4.17.10",
    "ngx-bootstrap": "^3.0.1",
    "ngx-cookie-service": "^1.0.10",
    "ngx-perfect-scrollbar": "^6.2.1",
    "reflect-metadata": "^0.1.12",
    "rxjs": "^6.2.1",
    "web-animations-js": "^2.3.1",
    "zone.js": "^0.8.26"
},
"devDependencies": {
    "@angular-devkit/build-optimizer": "^0.6.8",
    "@angular/cli": "6.0.8",
    "@angular/compiler-cli": "6.0.5",
    "@angular/language-service": "6.0.5",
    "@compodoc/compodoc": "^1.1.2",
    "@ngtools/webpack": "1.10.0",
    "@types/bootstrap": "^4.1.2",
    "@types/cryptojs": "^3.1.29",
    "@types/hammerjs": "^2.0.35",
    "@types/jasmine": "2.8.6",
    "@types/jquery": "^3.3.3",
    "@types/jquery.slimscroll": "^1.3.31",
    "@types/lodash": "^4.14.110",
    "@types/node": "^9.6.5",
    "@types/uglify-js": "^2.6.30",
    "@types/webpack": "^3.8.8",
    "add-asset-html-webpack-plugin": "~2.1.2",
    "angular2-template-loader": "^0.6.2",
    "assets-webpack-plugin": "^3.5.1",
    "awesome-typescript-loader": "^3.5.0",
    "codelyzer": "^4.2.1",
    "copy-webpack-plugin": "^4.5.1",
    "cross-env": "^5.1.4",
    "css-loader": "^0.28.11",
    "exports-loader": "^0.7.0",
    "expose-loader": "^0.7.5",
    "extract-text-webpack-plugin": "~3.0.2",
    "file-loader": "^1.1.9",
    "find-root": "^1.1.0",
    "gh-pages": "^1.1.0",
    "html-webpack-plugin": "^2.30.1",
    "imports-loader": "^0.8.0",
    "istanbul-instrumenter-loader": "~3.0.1",
    "jasmine-core": "^2.99.1",
    "karma": "^2.0.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-coverage": "^1.1.1",
    "karma-jasmine": "^1.1.0",
    "karma-mocha-reporter": "^2.2.5",
    "karma-remap-coverage": "^0.1.5",
    "karma-sourcemap-loader": "^0.3.7",
    "karma-webpack": "^2.0.11",
    "ngc-webpack": "^4.1.2",
    "ngx-i18nsupport": "^0.16.3",
    "node-sass": "^4.8.3",
    "npm-run-all": "^4.1.2",
    "optimize-js-plugin": "0.0.4",
    "parse5": "^4.0.0",
    "preload-webpack-plugin": "^2.3.0",
    "protractor": "^5.3.1",
    "raw-loader": "0.5.1",
    "resolve-url-loader": "^2.3.0",
    "rimraf": "~2.6.2",
    "sass-loader": "^7.0.1",
    "script-ext-html-webpack-plugin": "^1.8.8",
    "source-map-loader": "^0.2.3",
    "string-replace-loader": "~2.1.1",
    "style-loader": "^0.20.3",
    "to-string-loader": "^1.1.5",
    "ts-node": "^6.0.0",
    "tslib": "^1.9.0",
    "tslint": "^5.9.1",
    "tslint-loader": "^3.5.3",
    "typedoc": "^0.11.1",
    "typescript": "^2.7.2",
    "uglifyjs-webpack-plugin": "^1.2.4",
    "url-loader": "^1.0.1",
    "webpack": "^3.10.0",
    "webpack-dev-middleware": "^2.0.6",
    "webpack-dev-server": "~2.11.1",
    "webpack-inline-manifest-plugin": "4.0.0",
    "webpack-merge": "~4.1.2"
},
"repository": {},
"engines": {
    "node": ">= 8.0.0",
    "npm": ">= 5"
}

}

谢谢。

0 个答案:

没有答案