├── .angular-cli.json
├── .editorconfig
├── .gitignore
├── README.md
├── angular-cli.json
├── e2e
├── app.e2e-spec.ts
├── app.po.ts
└── tsconfig.json
├── karma.conf.js
├── package.json
├── protractor.conf.js
├── src
├── app
│ ├── app.component.css
│ ├── app.component.html
│ ├── app.component.spec.ts
│ ├── app.component.ts
│ └── app.module.ts
├── assets
│ └── .gitkeep
├── environments
│ ├── environment.prod.ts
│ └── environment.ts
├── favicon.ico
├── i18n
│ ├── messages.en.xlf
│ ├── messages.es.xlf
│ ├── messages.fr.xlf
│ └── messages.xlf
├── index.html
├── main.ts
├── polyfills.ts
├── styles.css
├── test.ts
└── tsconfig.json
├── tslint.json
├── webpack.config.js
├── webpack.en.config.js
├── webpack.es.config.js
├── webpack.fr.config.js
└── yarn.lock
/.angular-cli.json:
--------------------------------------------------------------------------------
1 | {
2 | "project": {
3 | "version": "1.0.0-beta.32.3",
4 | "name": "angular-cli-i18n-sample",
5 | "ejected": true
6 | },
7 | "apps": [
8 | {
9 | "root": "src",
10 | "outDir": "dist",
11 | "assets": [
12 | "assets",
13 | "favicon.ico"
14 | ],
15 | "index": "index.html",
16 | "main": "main.ts",
17 | "polyfills": "polyfills.ts",
18 | "test": "test.ts",
19 | "tsconfig": "tsconfig.json",
20 | "prefix": "app",
21 | "styles": [
22 | "styles.css"
23 | ],
24 | "scripts": [
25 | ],
26 | "environmentSource": "environments/environment.ts",
27 | "environments": {
28 | "dev": "environments/environment.ts",
29 | "prod": "environments/environment.prod.ts"
30 | }
31 | }
32 | ],
33 | "e2e": {
34 | "protractor": {
35 | "config": "./protractor.conf.js"
36 | }
37 | },
38 | "lint": [
39 | {
40 | "files": "src/**/*.ts",
41 | "project": "src/tsconfig.json"
42 | },
43 | {
44 | "files": "e2e/**/*.ts",
45 | "project": "e2e/tsconfig.json"
46 | }
47 | ],
48 | "test": {
49 | "karma": {
50 | "config": "./karma.conf.js"
51 | }
52 | },
53 | "defaults": {
54 | "styleExt": "css",
55 | "component": {
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | # Editor configuration, see http://editorconfig.org
2 | root = true
3 |
4 | [*]
5 | charset = utf-8
6 | indent_style = space
7 | indent_size = 2
8 | insert_final_newline = true
9 | trim_trailing_whitespace = true
10 |
11 | [*.md]
12 | max_line_length = off
13 | trim_trailing_whitespace = false
14 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # See http://help.github.com/ignore-files/ for more about ignoring files.
2 |
3 | # compiled output
4 | /dist
5 | /tmp
6 |
7 | # dependencies
8 | /node_modules
9 |
10 | # IDEs and editors
11 | /.idea
12 | .project
13 | .classpath
14 | .c9/
15 | *.launch
16 | .settings/
17 | *.sublime-workspace
18 |
19 | # IDE - VSCode
20 | .vscode/*
21 | !.vscode/settings.json
22 | !.vscode/tasks.json
23 | !.vscode/launch.json
24 | !.vscode/extensions.json
25 |
26 | # misc
27 | /.sass-cache
28 | /connect.lock
29 | /coverage/*
30 | /libpeerconnection.log
31 | npm-debug.log
32 | testem.log
33 | /typings
34 |
35 | # e2e
36 | /e2e/*.js
37 | /e2e/*.map
38 |
39 | #System Files
40 | .DS_Store
41 | Thumbs.db
42 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # AngularCliI18nSample
2 |
3 | This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 1.0.0-beta.32.3.
4 |
5 | ## Development server
6 | Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
7 |
8 | ## Code scaffolding
9 |
10 | Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive/pipe/service/class/module`.
11 |
12 | ## Build
13 |
14 | Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `-prod` flag for a production build.
15 |
16 | ## Running unit tests
17 |
18 | Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
19 |
20 | ## Running end-to-end tests
21 |
22 | Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).
23 | Before running the tests make sure you are serving the app via `ng serve`.
24 |
25 | ## Further help
26 |
27 | To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).
28 |
--------------------------------------------------------------------------------
/angular-cli.json:
--------------------------------------------------------------------------------
1 | {
2 | "project": {
3 | "version": "1.0.0-beta.24",
4 | "name": "angular-cli-i18n-sample"
5 | },
6 | "apps": [
7 | {
8 | "root": "src",
9 | "outDir": "dist",
10 | "assets": [
11 | "assets",
12 | "favicon.ico"
13 | ],
14 | "index": "index.html",
15 | "main": "main.ts",
16 | "test": "test.ts",
17 | "tsconfig": "tsconfig.json",
18 | "prefix": "app",
19 | "mobile": false,
20 | "styles": [
21 | "styles.css"
22 | ],
23 | "scripts": [],
24 | "environments": {
25 | "source": "environments/environment.ts",
26 | "dev": "environments/environment.ts",
27 | "prod": "environments/environment.prod.ts"
28 | }
29 | }
30 | ],
31 | "addons": [],
32 | "packages": [],
33 | "e2e": {
34 | "protractor": {
35 | "config": "./protractor.conf.js"
36 | }
37 | },
38 | "test": {
39 | "karma": {
40 | "config": "./karma.conf.js"
41 | }
42 | },
43 | "defaults": {
44 | "styleExt": "css",
45 | "prefixInterfaces": false,
46 | "inline": {
47 | "style": false,
48 | "template": false
49 | },
50 | "spec": {
51 | "class": false,
52 | "component": true,
53 | "directive": true,
54 | "module": false,
55 | "pipe": true,
56 | "service": true
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/e2e/app.e2e-spec.ts:
--------------------------------------------------------------------------------
1 | import { AngularCliI18nSamplePage } from './app.po';
2 |
3 | describe('angular-cli-i18n-sample App', () => {
4 | let page: AngularCliI18nSamplePage;
5 |
6 | beforeEach(() => {
7 | page = new AngularCliI18nSamplePage();
8 | });
9 |
10 | it('should display message saying app works', () => {
11 | page.navigateTo();
12 | expect(page.getParagraphText()).toEqual('app works!');
13 | });
14 | });
15 |
--------------------------------------------------------------------------------
/e2e/app.po.ts:
--------------------------------------------------------------------------------
1 | import { browser, element, by } from 'protractor';
2 |
3 | export class AngularCliI18nSamplePage {
4 | navigateTo() {
5 | return browser.get('/');
6 | }
7 |
8 | getParagraphText() {
9 | return element(by.css('app-root h1')).getText();
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/e2e/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compileOnSave": false,
3 | "compilerOptions": {
4 | "declaration": false,
5 | "emitDecoratorMetadata": true,
6 | "experimentalDecorators": true,
7 | "lib": [
8 | "es2016"
9 | ],
10 | "module": "commonjs",
11 | "moduleResolution": "node",
12 | "outDir": "../dist/out-tsc-e2e",
13 | "sourceMap": true,
14 | "target": "es6",
15 | "typeRoots": [
16 | "../node_modules/@types"
17 | ]
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/karma.conf.js:
--------------------------------------------------------------------------------
1 | // Karma configuration file, see link for more information
2 | // https://karma-runner.github.io/0.13/config/configuration-file.html
3 |
4 | module.exports = function (config) {
5 | config.set({
6 | basePath: '',
7 | frameworks: ['jasmine', '@angular/cli'],
8 | plugins: [
9 | require('karma-jasmine'),
10 | require('karma-chrome-launcher'),
11 | require('karma-jasmine-html-reporter'),
12 | require('karma-coverage-istanbul-reporter'),
13 | require('@angular/cli/plugins/karma')
14 | ],
15 | client:{
16 | clearContext: false // leave Jasmine Spec Runner output visible in browser
17 | },
18 | files: [
19 | { pattern: './src/test.ts', watched: false }
20 | ],
21 | preprocessors: {
22 | './src/test.ts': ['@angular/cli']
23 | },
24 | mime: {
25 | 'text/x-typescript': ['ts','tsx']
26 | },
27 | coverageIstanbulReporter: {
28 | reports: [ 'html', 'lcovonly' ],
29 | fixWebpackSourcePaths: true
30 | },
31 | angularCli: {
32 | config: './.angular-cli.json',
33 | environment: 'dev'
34 | },
35 | reporters: config.angularCli && config.angularCli.codeCoverage
36 | ? ['progress', 'coverage-istanbul']
37 | : ['progress', 'kjhtml'],
38 | port: 9876,
39 | colors: true,
40 | logLevel: config.LOG_INFO,
41 | autoWatch: true,
42 | browsers: ['Chrome'],
43 | singleRun: false
44 | });
45 | };
46 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "angular-cli-i18n-sample",
3 | "version": "0.0.0",
4 | "license": "MIT",
5 | "angular-cli": {},
6 | "scripts": {
7 | "ng": "ng",
8 | "start": "webpack-dev-server",
9 | "test": "karma start ./karma.conf.js",
10 | "lint": "ng lint",
11 | "e2e": "protractor ./protractor.conf.js",
12 | "build": "webpack --config webpack.fr.config.js && webpack --config webpack.en.config.js && webpack --config webpack.es.config.js"
13 | },
14 | "private": true,
15 | "dependencies": {
16 | "@angular/common": "^2.4.0",
17 | "@angular/compiler": "^2.4.0",
18 | "@angular/core": "^2.4.0",
19 | "@angular/forms": "^2.4.0",
20 | "@angular/http": "^2.4.0",
21 | "@angular/platform-browser": "^2.4.0",
22 | "@angular/platform-browser-dynamic": "^2.4.0",
23 | "@angular/router": "^3.4.0",
24 | "core-js": "^2.4.1",
25 | "rxjs": "^5.1.0",
26 | "zone.js": "^0.7.6"
27 | },
28 | "devDependencies": {
29 | "@angular/cli": "1.0.0-beta.32.3",
30 | "@angular/compiler-cli": "^2.4.0",
31 | "@types/jasmine": "2.5.38",
32 | "@types/node": "~6.0.60",
33 | "codelyzer": "~2.0.0-beta.4",
34 | "jasmine-core": "~2.5.2",
35 | "jasmine-spec-reporter": "~3.2.0",
36 | "karma": "~1.4.1",
37 | "karma-chrome-launcher": "~2.0.0",
38 | "karma-cli": "~1.0.1",
39 | "karma-jasmine": "~1.1.0",
40 | "karma-jasmine-html-reporter": "^0.2.2",
41 | "karma-coverage-istanbul-reporter": "^0.2.0",
42 | "protractor": "~5.1.0",
43 | "ts-node": "~2.0.0",
44 | "tslint": "~4.4.2",
45 | "typescript": "~2.0.0",
46 | "webpack-dev-server": "~2.3.0",
47 | "css-loader": "^0.26.1",
48 | "exports-loader": "^0.6.3",
49 | "file-loader": "^0.10.0",
50 | "json-loader": "^0.5.4",
51 | "karma-sourcemap-loader": "^0.3.7",
52 | "less-loader": "^2.2.3",
53 | "postcss-loader": "^0.13.0",
54 | "raw-loader": "^0.5.1",
55 | "sass-loader": "^4.1.1",
56 | "script-loader": "^0.7.0",
57 | "source-map-loader": "^0.1.5",
58 | "istanbul-instrumenter-loader": "^2.0.0",
59 | "style-loader": "^0.13.1",
60 | "stylus-loader": "^2.4.0",
61 | "url-loader": "^0.5.7"
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/protractor.conf.js:
--------------------------------------------------------------------------------
1 | // Protractor configuration file, see link for more information
2 | // https://github.com/angular/protractor/blob/master/lib/config.ts
3 |
4 | /*global jasmine */
5 | const { SpecReporter } = require('jasmine-spec-reporter');
6 |
7 | exports.config = {
8 | allScriptsTimeout: 11000,
9 | specs: [
10 | './e2e/**/*.e2e-spec.ts'
11 | ],
12 | capabilities: {
13 | 'browserName': 'chrome'
14 | },
15 | directConnect: true,
16 | baseUrl: 'http://localhost:4200/',
17 | framework: 'jasmine',
18 | jasmineNodeOpts: {
19 | showColors: true,
20 | defaultTimeoutInterval: 30000,
21 | print: function() {}
22 | },
23 | beforeLaunch: function() {
24 | require('ts-node').register({
25 | project: 'e2e'
26 | });
27 | },
28 | onPrepare() {
29 | jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
30 | }
31 | };
32 |
--------------------------------------------------------------------------------
/src/app/app.component.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feloy/angular-cli-i18n-sample/1fea4f525a5e5322bff1f2ebaa306e213575fb67/src/app/app.component.css
--------------------------------------------------------------------------------
/src/app/app.component.html:
--------------------------------------------------------------------------------
1 |
Hello World!
2 |
--------------------------------------------------------------------------------
/src/app/app.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { TestBed, async } from '@angular/core/testing';
2 | import { AppComponent } from './app.component';
3 |
4 | describe('AppComponent', () => {
5 | beforeEach(() => {
6 | TestBed.configureTestingModule({
7 | declarations: [
8 | AppComponent
9 | ],
10 | });
11 | TestBed.compileComponents();
12 | });
13 |
14 | it('should create the app', async(() => {
15 | const fixture = TestBed.createComponent(AppComponent);
16 | const app = fixture.debugElement.componentInstance;
17 | expect(app).toBeTruthy();
18 | }));
19 |
20 | it(`should have as title 'app works!'`, async(() => {
21 | const fixture = TestBed.createComponent(AppComponent);
22 | const app = fixture.debugElement.componentInstance;
23 | expect(app.title).toEqual('app works!');
24 | }));
25 |
26 | it('should render title in a h1 tag', async(() => {
27 | const fixture = TestBed.createComponent(AppComponent);
28 | fixture.detectChanges();
29 | const compiled = fixture.debugElement.nativeElement;
30 | expect(compiled.querySelector('h1').textContent).toContain('app works!');
31 | }));
32 | });
33 |
--------------------------------------------------------------------------------
/src/app/app.component.ts:
--------------------------------------------------------------------------------
1 | import { Component } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-root',
5 | templateUrl: './app.component.html',
6 | styleUrls: ['./app.component.css']
7 | })
8 | export class AppComponent {
9 | title = 'app works!';
10 | }
11 |
--------------------------------------------------------------------------------
/src/app/app.module.ts:
--------------------------------------------------------------------------------
1 | import { BrowserModule } from '@angular/platform-browser';
2 | import { NgModule } from '@angular/core';
3 | import { FormsModule } from '@angular/forms';
4 | import { HttpModule } from '@angular/http';
5 |
6 | import { AppComponent } from './app.component';
7 |
8 | @NgModule({
9 | declarations: [
10 | AppComponent
11 | ],
12 | imports: [
13 | BrowserModule,
14 | FormsModule,
15 | HttpModule
16 | ],
17 | providers: [],
18 | bootstrap: [AppComponent]
19 | })
20 | export class AppModule { }
21 |
--------------------------------------------------------------------------------
/src/assets/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feloy/angular-cli-i18n-sample/1fea4f525a5e5322bff1f2ebaa306e213575fb67/src/assets/.gitkeep
--------------------------------------------------------------------------------
/src/environments/environment.prod.ts:
--------------------------------------------------------------------------------
1 | export const environment = {
2 | production: true
3 | };
4 |
--------------------------------------------------------------------------------
/src/environments/environment.ts:
--------------------------------------------------------------------------------
1 | // The file contents for the current environment will overwrite these during build.
2 | // The build system defaults to the dev environment which uses `environment.ts`, but if you do
3 | // `ng build --env=prod` then `environment.prod.ts` will be used instead.
4 | // The list of which env maps to which file can be found in `.angular-cli.json`.
5 |
6 | export const environment = {
7 | production: false
8 | };
9 |
--------------------------------------------------------------------------------
/src/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/feloy/angular-cli-i18n-sample/1fea4f525a5e5322bff1f2ebaa306e213575fb67/src/favicon.ico
--------------------------------------------------------------------------------
/src/i18n/messages.en.xlf:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Hello World!
7 | Hello World!
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/src/i18n/messages.es.xlf:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Hello World!
7 | ¿hola, qué tal?
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/src/i18n/messages.fr.xlf:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Hello World!
7 | Salut la foule !
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/src/i18n/messages.xlf:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Hello World!
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | AngularCliI18nSample
6 |
7 |
8 |
9 |
10 |
11 |
12 | Loading...
13 |
14 |
15 |
--------------------------------------------------------------------------------
/src/main.ts:
--------------------------------------------------------------------------------
1 | import { enableProdMode } from '@angular/core';
2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
3 |
4 | import { AppModule } from './app/app.module';
5 | import { environment } from './environments/environment';
6 |
7 | if (environment.production) {
8 | enableProdMode();
9 | }
10 |
11 | platformBrowserDynamic().bootstrapModule(AppModule);
12 |
--------------------------------------------------------------------------------
/src/polyfills.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * This file includes polyfills needed by Angular and is loaded before the app.
3 | * You can add your own extra polyfills to this file.
4 | *
5 | * This file is divided into 2 sections:
6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main
8 | * file.
9 | *
10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that
11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
13 | *
14 | * Learn more in https://angular.io/docs/ts/latest/guide/browser-support.html
15 | */
16 |
17 | /***************************************************************************************************
18 | * BROWSER POLYFILLS
19 | */
20 |
21 | /** IE9, IE10 and IE11 requires all of the following polyfills. **/
22 | // import 'core-js/es6/symbol';
23 | // import 'core-js/es6/object';
24 | // import 'core-js/es6/function';
25 | // import 'core-js/es6/parse-int';
26 | // import 'core-js/es6/parse-float';
27 | // import 'core-js/es6/number';
28 | // import 'core-js/es6/math';
29 | // import 'core-js/es6/string';
30 | // import 'core-js/es6/date';
31 | // import 'core-js/es6/array';
32 | // import 'core-js/es6/regexp';
33 | // import 'core-js/es6/map';
34 | // import 'core-js/es6/set';
35 |
36 | /** IE10 and IE11 requires the following for NgClass support on SVG elements */
37 | // import 'classlist.js'; // Run `npm install --save classlist.js`.
38 |
39 | /** IE10 and IE11 requires the following to support `@angular/animation`. */
40 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`.
41 |
42 |
43 | /** Evergreen browsers require these. **/
44 | import 'core-js/es6/reflect';
45 | import 'core-js/es7/reflect';
46 |
47 |
48 | /** ALL Firefox browsers require the following to support `@angular/animation`. **/
49 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`.
50 |
51 |
52 |
53 | /***************************************************************************************************
54 | * Zone JS is required by Angular itself.
55 | */
56 | import 'zone.js/dist/zone'; // Included with Angular CLI.
57 |
58 |
59 |
60 | /***************************************************************************************************
61 | * APPLICATION IMPORTS
62 | */
63 |
64 | /**
65 | * Date, currency, decimal and percent pipes.
66 | * Needed for: All but Chrome, Firefox, Edge, IE11 and Safari 10
67 | */
68 | // import 'intl'; // Run `npm install --save intl`.
69 |
--------------------------------------------------------------------------------
/src/styles.css:
--------------------------------------------------------------------------------
1 | /* You can add global styles to this file, and also import other style files */
2 |
--------------------------------------------------------------------------------
/src/test.ts:
--------------------------------------------------------------------------------
1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files
2 |
3 | import 'zone.js/dist/long-stack-trace-zone';
4 | import 'zone.js/dist/proxy.js';
5 | import 'zone.js/dist/sync-test';
6 | import 'zone.js/dist/jasmine-patch';
7 | import 'zone.js/dist/async-test';
8 | import 'zone.js/dist/fake-async-test';
9 | import { getTestBed } from '@angular/core/testing';
10 | import {
11 | BrowserDynamicTestingModule,
12 | platformBrowserDynamicTesting
13 | } from '@angular/platform-browser-dynamic/testing';
14 |
15 | // Unfortunately there's no typing for the `__karma__` variable. Just declare it as any.
16 | declare var __karma__: any;
17 | declare var require: any;
18 |
19 | // Prevent Karma from running prematurely.
20 | __karma__.loaded = function () {};
21 |
22 | // First, initialize the Angular testing environment.
23 | getTestBed().initTestEnvironment(
24 | BrowserDynamicTestingModule,
25 | platformBrowserDynamicTesting()
26 | );
27 | // Then we find all the tests.
28 | const context = require.context('./', true, /\.spec\.ts$/);
29 | // And load the modules.
30 | context.keys().map(context);
31 | // Finally, start Karma to run the tests.
32 | __karma__.start();
33 |
--------------------------------------------------------------------------------
/src/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "baseUrl": "",
4 | "declaration": false,
5 | "emitDecoratorMetadata": true,
6 | "experimentalDecorators": true,
7 | "lib": [
8 | "es2016",
9 | "dom"
10 | ],
11 | "mapRoot": "./",
12 | "module": "es2015",
13 | "moduleResolution": "node",
14 | "outDir": "../dist/out-tsc",
15 | "sourceMap": true,
16 | "target": "es5",
17 | "typeRoots": [
18 | "../node_modules/@types"
19 | ]
20 | },
21 | "exclude": [
22 | "test.ts",
23 | "**/*.spec.ts"
24 | ]
25 | }
--------------------------------------------------------------------------------
/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "rulesDirectory": [
3 | "node_modules/codelyzer"
4 | ],
5 | "rules": {
6 | "callable-types": true,
7 | "class-name": true,
8 | "comment-format": [
9 | true,
10 | "check-space"
11 | ],
12 | "curly": true,
13 | "eofline": true,
14 | "forin": true,
15 | "import-blacklist": [true, "rxjs"],
16 | "import-spacing": true,
17 | "indent": [
18 | true,
19 | "spaces"
20 | ],
21 | "interface-over-type-literal": true,
22 | "label-position": true,
23 | "max-line-length": [
24 | true,
25 | 140
26 | ],
27 | "member-access": false,
28 | "member-ordering": [
29 | true,
30 | "static-before-instance",
31 | "variables-before-functions"
32 | ],
33 | "no-arg": true,
34 | "no-bitwise": true,
35 | "no-console": [
36 | true,
37 | "debug",
38 | "info",
39 | "time",
40 | "timeEnd",
41 | "trace"
42 | ],
43 | "no-construct": true,
44 | "no-debugger": true,
45 | "no-duplicate-variable": true,
46 | "no-empty": false,
47 | "no-empty-interface": true,
48 | "no-eval": true,
49 | "no-inferrable-types": [true, "ignore-params"],
50 | "no-shadowed-variable": true,
51 | "no-string-literal": false,
52 | "no-string-throw": true,
53 | "no-switch-case-fall-through": true,
54 | "no-trailing-whitespace": true,
55 | "no-unused-expression": true,
56 | "no-use-before-declare": true,
57 | "no-var-keyword": true,
58 | "object-literal-sort-keys": false,
59 | "one-line": [
60 | true,
61 | "check-open-brace",
62 | "check-catch",
63 | "check-else",
64 | "check-whitespace"
65 | ],
66 | "prefer-const": true,
67 | "quotemark": [
68 | true,
69 | "single"
70 | ],
71 | "radix": true,
72 | "semicolon": [
73 | "always"
74 | ],
75 | "triple-equals": [
76 | true,
77 | "allow-null-check"
78 | ],
79 | "typedef-whitespace": [
80 | true,
81 | {
82 | "call-signature": "nospace",
83 | "index-signature": "nospace",
84 | "parameter": "nospace",
85 | "property-declaration": "nospace",
86 | "variable-declaration": "nospace"
87 | }
88 | ],
89 | "typeof-compare": true,
90 | "unified-signatures": true,
91 | "variable-name": false,
92 | "whitespace": [
93 | true,
94 | "check-branch",
95 | "check-decl",
96 | "check-operator",
97 | "check-separator",
98 | "check-type"
99 | ],
100 |
101 | "directive-selector": [true, "attribute", "app", "camelCase"],
102 | "component-selector": [true, "element", "app", "kebab-case"],
103 | "use-input-property-decorator": true,
104 | "use-output-property-decorator": true,
105 | "use-host-property-decorator": true,
106 | "no-input-rename": true,
107 | "no-output-rename": true,
108 | "use-life-cycle-interface": true,
109 | "use-pipe-transform-interface": true,
110 | "component-class-suffix": true,
111 | "directive-class-suffix": true,
112 | "no-access-missing-member": true,
113 | "templates-use-public": true,
114 | "invoke-injectable": true
115 | }
116 | }
117 |
--------------------------------------------------------------------------------
/webpack.config.js:
--------------------------------------------------------------------------------
1 | const path = require('path');
2 | const HtmlWebpackPlugin = require('html-webpack-plugin');
3 | const ProgressPlugin = require('webpack/lib/ProgressPlugin');
4 | const ExtractTextPlugin = require('extract-text-webpack-plugin');
5 | const autoprefixer = require('autoprefixer');
6 | const cssnano = require('cssnano');
7 |
8 | const { NoEmitOnErrorsPlugin, LoaderOptionsPlugin, DefinePlugin } = require('webpack');
9 | const { BaseHrefWebpackPlugin, GlobCopyWebpackPlugin, SuppressExtractedTextChunksWebpackPlugin } = require('@angular/cli/plugins/webpack');
10 | const { CommonsChunkPlugin, UglifyJsPlugin } = require('webpack').optimize;
11 | const { AotPlugin } = require('@ngtools/webpack');
12 |
13 | const nodeModules = path.join(process.cwd(), 'node_modules');
14 | const entryPoints = ["inline","polyfills","sw-register","styles","vendor","main"];
15 |
16 |
17 |
18 |
19 | module.exports = {
20 | "devtool": false,
21 | "resolve": {
22 | "extensions": [
23 | ".ts",
24 | ".js"
25 | ],
26 | "modules": [
27 | "./node_modules"
28 | ]
29 | },
30 | "resolveLoader": {
31 | "modules": [
32 | "./node_modules"
33 | ]
34 | },
35 | "entry": {
36 | "main": [
37 | "./src/main.ts"
38 | ],
39 | "polyfills": [
40 | "./src/polyfills.ts"
41 | ],
42 | "styles": [
43 | "./src/styles.css"
44 | ]
45 | },
46 | "output": {
47 | "path": path.join(process.cwd(), "dist/fr"),
48 | "filename": "[name].[chunkhash:20].bundle.js",
49 | "chunkFilename": "[id].[chunkhash:20].chunk.js"
50 | },
51 | "module": {
52 | "rules": [
53 | {
54 | "enforce": "pre",
55 | "test": /\.js$/,
56 | "loader": "source-map-loader",
57 | "exclude": [
58 | /\/node_modules\//
59 | ]
60 | },
61 | {
62 | "test": /\.json$/,
63 | "loader": "json-loader"
64 | },
65 | {
66 | "test": /\.html$/,
67 | "loader": "raw-loader"
68 | },
69 | {
70 | "test": /\.(eot|svg)$/,
71 | "loader": "file-loader?name=[name].[hash:20].[ext]"
72 | },
73 | {
74 | "test": /\.(jpg|png|gif|otf|ttf|woff|woff2|cur|ani)$/,
75 | "loader": "url-loader?name=[name].[hash:20].[ext]&limit=10000"
76 | },
77 | {
78 | "exclude": [
79 | path.join(process.cwd(), "src/styles.css")
80 | ],
81 | "test": /\.css$/,
82 | "loaders": [
83 | "exports-loader?module.exports.toString()",
84 | "css-loader?{\"sourceMap\":false,\"importLoaders\":1}",
85 | "postcss-loader"
86 | ]
87 | },
88 | {
89 | "exclude": [
90 | path.join(process.cwd(), "src/styles.css")
91 | ],
92 | "test": /\.scss$|\.sass$/,
93 | "loaders": [
94 | "exports-loader?module.exports.toString()",
95 | "css-loader?{\"sourceMap\":false,\"importLoaders\":1}",
96 | "postcss-loader",
97 | "sass-loader"
98 | ]
99 | },
100 | {
101 | "exclude": [
102 | path.join(process.cwd(), "src/styles.css")
103 | ],
104 | "test": /\.less$/,
105 | "loaders": [
106 | "exports-loader?module.exports.toString()",
107 | "css-loader?{\"sourceMap\":false,\"importLoaders\":1}",
108 | "postcss-loader",
109 | "less-loader"
110 | ]
111 | },
112 | {
113 | "exclude": [
114 | path.join(process.cwd(), "src/styles.css")
115 | ],
116 | "test": /\.styl$/,
117 | "loaders": [
118 | "exports-loader?module.exports.toString()",
119 | "css-loader?{\"sourceMap\":false,\"importLoaders\":1}",
120 | "postcss-loader",
121 | "stylus-loader?{\"sourceMap\":false,\"paths\":[]}"
122 | ]
123 | },
124 | {
125 | "include": [
126 | path.join(process.cwd(), "src/styles.css")
127 | ],
128 | "test": /\.css$/,
129 | "loaders": ExtractTextPlugin.extract({
130 | "use": [
131 | "css-loader?{\"sourceMap\":false,\"importLoaders\":1}",
132 | "postcss-loader"
133 | ],
134 | "fallback": "style-loader",
135 | "publicPath": ""
136 | })
137 | },
138 | {
139 | "include": [
140 | path.join(process.cwd(), "src/styles.css")
141 | ],
142 | "test": /\.scss$|\.sass$/,
143 | "loaders": ExtractTextPlugin.extract({
144 | "use": [
145 | "css-loader?{\"sourceMap\":false,\"importLoaders\":1}",
146 | "postcss-loader",
147 | "sass-loader"
148 | ],
149 | "fallback": "style-loader",
150 | "publicPath": ""
151 | })
152 | },
153 | {
154 | "include": [
155 | path.join(process.cwd(), "src/styles.css")
156 | ],
157 | "test": /\.less$/,
158 | "loaders": ExtractTextPlugin.extract({
159 | "use": [
160 | "css-loader?{\"sourceMap\":false,\"importLoaders\":1}",
161 | "postcss-loader",
162 | "less-loader"
163 | ],
164 | "fallback": "style-loader",
165 | "publicPath": ""
166 | })
167 | },
168 | {
169 | "include": [
170 | path.join(process.cwd(), "src/styles.css")
171 | ],
172 | "test": /\.styl$/,
173 | "loaders": ExtractTextPlugin.extract({
174 | "use": [
175 | "css-loader?{\"sourceMap\":false,\"importLoaders\":1}",
176 | "postcss-loader",
177 | "stylus-loader?{\"sourceMap\":false,\"paths\":[]}"
178 | ],
179 | "fallback": "style-loader",
180 | "publicPath": ""
181 | })
182 | },
183 | {
184 | "test": /\.ts$/,
185 | "loader": "@ngtools/webpack",
186 | "exclude": [
187 | /\.(spec|e2e)\.ts$/
188 | ]
189 | }
190 | ]
191 | },
192 | "plugins": [
193 | new NoEmitOnErrorsPlugin(),
194 | new HtmlWebpackPlugin({
195 | "template": "./src/index.html",
196 | "filename": "./index.html",
197 | "hash": false,
198 | "inject": true,
199 | "compile": true,
200 | "favicon": false,
201 | "minify": false,
202 | "cache": true,
203 | "showErrors": true,
204 | "chunks": "all",
205 | "excludeChunks": [],
206 | "title": "Webpack App",
207 | "xhtml": true,
208 | "chunksSortMode": function sort(left, right) {
209 | let leftIndex = entryPoints.indexOf(left.names[0]);
210 | let rightindex = entryPoints.indexOf(right.names[0]);
211 | if (leftIndex > rightindex) {
212 | return 1;
213 | }
214 | else if (leftIndex < rightindex) {
215 | return -1;
216 | }
217 | else {
218 | return 0;
219 | }
220 | }
221 | }),
222 | new BaseHrefWebpackPlugin({
223 | "baseHref": "/fr/"
224 | }),
225 | new CommonsChunkPlugin({
226 | "name": "inline",
227 | "minChunks": null
228 | }),
229 | new CommonsChunkPlugin({
230 | "name": "vendor",
231 | "minChunks": (module) => module.resource && module.resource.startsWith(nodeModules),
232 | "chunks": [
233 | "main"
234 | ]
235 | }),
236 | new GlobCopyWebpackPlugin({
237 | "patterns": [
238 | "assets",
239 | "favicon.ico"
240 | ],
241 | "globOptions": {
242 | "cwd": "/home/philippe/Devs/MEDIUM/angular-cli-i18n-sample/src",
243 | "dot": true,
244 | "ignore": "**/.gitkeep"
245 | }
246 | }),
247 | new ProgressPlugin(),
248 | new ExtractTextPlugin({
249 | "filename": "[name].[contenthash:20].bundle.css",
250 | "disable": false
251 | }),
252 | new LoaderOptionsPlugin({
253 | "sourceMap": false,
254 | "options": {
255 | "postcss": [
256 | autoprefixer(),
257 | cssnano({ safe: true, autoprefixer: false })
258 | ],
259 | "sassLoader": {
260 | "sourceMap": false,
261 | "includePaths": []
262 | },
263 | "lessLoader": {
264 | "sourceMap": false
265 | },
266 | "context": ""
267 | }
268 | }),
269 | new SuppressExtractedTextChunksWebpackPlugin(),
270 | new DefinePlugin({
271 | "process.env.NODE_ENV": "\"production\""
272 | }),
273 | new UglifyJsPlugin({
274 | "mangle": {
275 | "screw_ie8": true
276 | },
277 | "compress": {
278 | "screw_ie8": true,
279 | "warnings": false
280 | },
281 | "sourceMap": false
282 | }),
283 | new AotPlugin({
284 | "tsConfigPath": "src/tsconfig.json",
285 | "mainPath": "main.ts",
286 | "i18nFile": "src/i18n/messages.fr.xlf",
287 | "i18nFormat": "xlf",
288 | "locale": "fr",
289 | "hostReplacementPaths": {
290 | "environments/environment.ts": "environments/environment.prod.ts"
291 | },
292 | "exclude": [
293 | "**/*.spec.ts",
294 | "test.ts"
295 | ]
296 | })
297 | ],
298 | "node": {
299 | "fs": "empty",
300 | "global": true,
301 | "crypto": "empty",
302 | "tls": "empty",
303 | "net": "empty",
304 | "process": true,
305 | "module": false,
306 | "clearImmediate": false,
307 | "setImmediate": false
308 | }
309 | };
310 |
--------------------------------------------------------------------------------
/webpack.en.config.js:
--------------------------------------------------------------------------------
1 | const path = require('path');
2 | const HtmlWebpackPlugin = require('html-webpack-plugin');
3 | const ProgressPlugin = require('webpack/lib/ProgressPlugin');
4 | const ExtractTextPlugin = require('extract-text-webpack-plugin');
5 | const autoprefixer = require('autoprefixer');
6 | const cssnano = require('cssnano');
7 |
8 | const { NoEmitOnErrorsPlugin, LoaderOptionsPlugin, DefinePlugin } = require('webpack');
9 | const { BaseHrefWebpackPlugin, GlobCopyWebpackPlugin, SuppressExtractedTextChunksWebpackPlugin } = require('@angular/cli/plugins/webpack');
10 | const { CommonsChunkPlugin, UglifyJsPlugin } = require('webpack').optimize;
11 | const { AotPlugin } = require('@ngtools/webpack');
12 |
13 | const nodeModules = path.join(process.cwd(), 'node_modules');
14 | const entryPoints = ["inline","polyfills","sw-register","styles","vendor","main"];
15 |
16 |
17 |
18 |
19 | module.exports = {
20 | "devtool": false,
21 | "resolve": {
22 | "extensions": [
23 | ".ts",
24 | ".js"
25 | ],
26 | "modules": [
27 | "./node_modules"
28 | ]
29 | },
30 | "resolveLoader": {
31 | "modules": [
32 | "./node_modules"
33 | ]
34 | },
35 | "entry": {
36 | "main": [
37 | "./src/main.ts"
38 | ],
39 | "polyfills": [
40 | "./src/polyfills.ts"
41 | ],
42 | "styles": [
43 | "./src/styles.css"
44 | ]
45 | },
46 | "output": {
47 | "path": path.join(process.cwd(), "dist/en"),
48 | "filename": "[name].[chunkhash:20].bundle.js",
49 | "chunkFilename": "[id].[chunkhash:20].chunk.js"
50 | },
51 | "module": {
52 | "rules": [
53 | {
54 | "enforce": "pre",
55 | "test": /\.js$/,
56 | "loader": "source-map-loader",
57 | "exclude": [
58 | /\/node_modules\//
59 | ]
60 | },
61 | {
62 | "test": /\.json$/,
63 | "loader": "json-loader"
64 | },
65 | {
66 | "test": /\.html$/,
67 | "loader": "raw-loader"
68 | },
69 | {
70 | "test": /\.(eot|svg)$/,
71 | "loader": "file-loader?name=[name].[hash:20].[ext]"
72 | },
73 | {
74 | "test": /\.(jpg|png|gif|otf|ttf|woff|woff2|cur|ani)$/,
75 | "loader": "url-loader?name=[name].[hash:20].[ext]&limit=10000"
76 | },
77 | {
78 | "exclude": [
79 | path.join(process.cwd(), "src/styles.css")
80 | ],
81 | "test": /\.css$/,
82 | "loaders": [
83 | "exports-loader?module.exports.toString()",
84 | "css-loader?{\"sourceMap\":false,\"importLoaders\":1}",
85 | "postcss-loader"
86 | ]
87 | },
88 | {
89 | "exclude": [
90 | path.join(process.cwd(), "src/styles.css")
91 | ],
92 | "test": /\.scss$|\.sass$/,
93 | "loaders": [
94 | "exports-loader?module.exports.toString()",
95 | "css-loader?{\"sourceMap\":false,\"importLoaders\":1}",
96 | "postcss-loader",
97 | "sass-loader"
98 | ]
99 | },
100 | {
101 | "exclude": [
102 | path.join(process.cwd(), "src/styles.css")
103 | ],
104 | "test": /\.less$/,
105 | "loaders": [
106 | "exports-loader?module.exports.toString()",
107 | "css-loader?{\"sourceMap\":false,\"importLoaders\":1}",
108 | "postcss-loader",
109 | "less-loader"
110 | ]
111 | },
112 | {
113 | "exclude": [
114 | path.join(process.cwd(), "src/styles.css")
115 | ],
116 | "test": /\.styl$/,
117 | "loaders": [
118 | "exports-loader?module.exports.toString()",
119 | "css-loader?{\"sourceMap\":false,\"importLoaders\":1}",
120 | "postcss-loader",
121 | "stylus-loader?{\"sourceMap\":false,\"paths\":[]}"
122 | ]
123 | },
124 | {
125 | "include": [
126 | path.join(process.cwd(), "src/styles.css")
127 | ],
128 | "test": /\.css$/,
129 | "loaders": ExtractTextPlugin.extract({
130 | "use": [
131 | "css-loader?{\"sourceMap\":false,\"importLoaders\":1}",
132 | "postcss-loader"
133 | ],
134 | "fallback": "style-loader",
135 | "publicPath": ""
136 | })
137 | },
138 | {
139 | "include": [
140 | path.join(process.cwd(), "src/styles.css")
141 | ],
142 | "test": /\.scss$|\.sass$/,
143 | "loaders": ExtractTextPlugin.extract({
144 | "use": [
145 | "css-loader?{\"sourceMap\":false,\"importLoaders\":1}",
146 | "postcss-loader",
147 | "sass-loader"
148 | ],
149 | "fallback": "style-loader",
150 | "publicPath": ""
151 | })
152 | },
153 | {
154 | "include": [
155 | path.join(process.cwd(), "src/styles.css")
156 | ],
157 | "test": /\.less$/,
158 | "loaders": ExtractTextPlugin.extract({
159 | "use": [
160 | "css-loader?{\"sourceMap\":false,\"importLoaders\":1}",
161 | "postcss-loader",
162 | "less-loader"
163 | ],
164 | "fallback": "style-loader",
165 | "publicPath": ""
166 | })
167 | },
168 | {
169 | "include": [
170 | path.join(process.cwd(), "src/styles.css")
171 | ],
172 | "test": /\.styl$/,
173 | "loaders": ExtractTextPlugin.extract({
174 | "use": [
175 | "css-loader?{\"sourceMap\":false,\"importLoaders\":1}",
176 | "postcss-loader",
177 | "stylus-loader?{\"sourceMap\":false,\"paths\":[]}"
178 | ],
179 | "fallback": "style-loader",
180 | "publicPath": ""
181 | })
182 | },
183 | {
184 | "test": /\.ts$/,
185 | "loader": "@ngtools/webpack",
186 | "exclude": [
187 | /\.(spec|e2e)\.ts$/
188 | ]
189 | }
190 | ]
191 | },
192 | "plugins": [
193 | new NoEmitOnErrorsPlugin(),
194 | new HtmlWebpackPlugin({
195 | "template": "./src/index.html",
196 | "filename": "./index.html",
197 | "hash": false,
198 | "inject": true,
199 | "compile": true,
200 | "favicon": false,
201 | "minify": false,
202 | "cache": true,
203 | "showErrors": true,
204 | "chunks": "all",
205 | "excludeChunks": [],
206 | "title": "Webpack App",
207 | "xhtml": true,
208 | "chunksSortMode": function sort(left, right) {
209 | let leftIndex = entryPoints.indexOf(left.names[0]);
210 | let rightindex = entryPoints.indexOf(right.names[0]);
211 | if (leftIndex > rightindex) {
212 | return 1;
213 | }
214 | else if (leftIndex < rightindex) {
215 | return -1;
216 | }
217 | else {
218 | return 0;
219 | }
220 | }
221 | }),
222 | new BaseHrefWebpackPlugin({
223 | "baseHref": "/en/"
224 | }),
225 | new CommonsChunkPlugin({
226 | "name": "inline",
227 | "minChunks": null
228 | }),
229 | new CommonsChunkPlugin({
230 | "name": "vendor",
231 | "minChunks": (module) => module.resource && module.resource.startsWith(nodeModules),
232 | "chunks": [
233 | "main"
234 | ]
235 | }),
236 | new GlobCopyWebpackPlugin({
237 | "patterns": [
238 | "assets",
239 | "favicon.ico"
240 | ],
241 | "globOptions": {
242 | "cwd": "/home/philippe/Devs/MEDIUM/angular-cli-i18n-sample/src",
243 | "dot": true,
244 | "ignore": "**/.gitkeep"
245 | }
246 | }),
247 | new ProgressPlugin(),
248 | new ExtractTextPlugin({
249 | "filename": "[name].[contenthash:20].bundle.css",
250 | "disable": false
251 | }),
252 | new LoaderOptionsPlugin({
253 | "sourceMap": false,
254 | "options": {
255 | "postcss": [
256 | autoprefixer(),
257 | cssnano({ safe: true, autoprefixer: false })
258 | ],
259 | "sassLoader": {
260 | "sourceMap": false,
261 | "includePaths": []
262 | },
263 | "lessLoader": {
264 | "sourceMap": false
265 | },
266 | "context": ""
267 | }
268 | }),
269 | new SuppressExtractedTextChunksWebpackPlugin(),
270 | new DefinePlugin({
271 | "process.env.NODE_ENV": "\"production\""
272 | }),
273 | new UglifyJsPlugin({
274 | "mangle": {
275 | "screw_ie8": true
276 | },
277 | "compress": {
278 | "screw_ie8": true,
279 | "warnings": false
280 | },
281 | "sourceMap": false
282 | }),
283 | new AotPlugin({
284 | "tsConfigPath": "src/tsconfig.json",
285 | "mainPath": "main.ts",
286 | "i18nFile": "src/i18n/messages.en.xlf",
287 | "i18nFormat": "xlf",
288 | "locale": "en",
289 | "hostReplacementPaths": {
290 | "environments/environment.ts": "environments/environment.prod.ts"
291 | },
292 | "exclude": [
293 | "**/*.spec.ts",
294 | "test.ts"
295 | ]
296 | })
297 | ],
298 | "node": {
299 | "fs": "empty",
300 | "global": true,
301 | "crypto": "empty",
302 | "tls": "empty",
303 | "net": "empty",
304 | "process": true,
305 | "module": false,
306 | "clearImmediate": false,
307 | "setImmediate": false
308 | }
309 | };
310 |
--------------------------------------------------------------------------------
/webpack.es.config.js:
--------------------------------------------------------------------------------
1 | const path = require('path');
2 | const HtmlWebpackPlugin = require('html-webpack-plugin');
3 | const ProgressPlugin = require('webpack/lib/ProgressPlugin');
4 | const ExtractTextPlugin = require('extract-text-webpack-plugin');
5 | const autoprefixer = require('autoprefixer');
6 | const cssnano = require('cssnano');
7 |
8 | const { NoEmitOnErrorsPlugin, LoaderOptionsPlugin, DefinePlugin } = require('webpack');
9 | const { BaseHrefWebpackPlugin, GlobCopyWebpackPlugin, SuppressExtractedTextChunksWebpackPlugin } = require('@angular/cli/plugins/webpack');
10 | const { CommonsChunkPlugin, UglifyJsPlugin } = require('webpack').optimize;
11 | const { AotPlugin } = require('@ngtools/webpack');
12 |
13 | const nodeModules = path.join(process.cwd(), 'node_modules');
14 | const entryPoints = ["inline","polyfills","sw-register","styles","vendor","main"];
15 |
16 |
17 |
18 |
19 | module.exports = {
20 | "devtool": false,
21 | "resolve": {
22 | "extensions": [
23 | ".ts",
24 | ".js"
25 | ],
26 | "modules": [
27 | "./node_modules"
28 | ]
29 | },
30 | "resolveLoader": {
31 | "modules": [
32 | "./node_modules"
33 | ]
34 | },
35 | "entry": {
36 | "main": [
37 | "./src/main.ts"
38 | ],
39 | "polyfills": [
40 | "./src/polyfills.ts"
41 | ],
42 | "styles": [
43 | "./src/styles.css"
44 | ]
45 | },
46 | "output": {
47 | "path": path.join(process.cwd(), "dist/es"),
48 | "filename": "[name].[chunkhash:20].bundle.js",
49 | "chunkFilename": "[id].[chunkhash:20].chunk.js"
50 | },
51 | "module": {
52 | "rules": [
53 | {
54 | "enforce": "pre",
55 | "test": /\.js$/,
56 | "loader": "source-map-loader",
57 | "exclude": [
58 | /\/node_modules\//
59 | ]
60 | },
61 | {
62 | "test": /\.json$/,
63 | "loader": "json-loader"
64 | },
65 | {
66 | "test": /\.html$/,
67 | "loader": "raw-loader"
68 | },
69 | {
70 | "test": /\.(eot|svg)$/,
71 | "loader": "file-loader?name=[name].[hash:20].[ext]"
72 | },
73 | {
74 | "test": /\.(jpg|png|gif|otf|ttf|woff|woff2|cur|ani)$/,
75 | "loader": "url-loader?name=[name].[hash:20].[ext]&limit=10000"
76 | },
77 | {
78 | "exclude": [
79 | path.join(process.cwd(), "src/styles.css")
80 | ],
81 | "test": /\.css$/,
82 | "loaders": [
83 | "exports-loader?module.exports.toString()",
84 | "css-loader?{\"sourceMap\":false,\"importLoaders\":1}",
85 | "postcss-loader"
86 | ]
87 | },
88 | {
89 | "exclude": [
90 | path.join(process.cwd(), "src/styles.css")
91 | ],
92 | "test": /\.scss$|\.sass$/,
93 | "loaders": [
94 | "exports-loader?module.exports.toString()",
95 | "css-loader?{\"sourceMap\":false,\"importLoaders\":1}",
96 | "postcss-loader",
97 | "sass-loader"
98 | ]
99 | },
100 | {
101 | "exclude": [
102 | path.join(process.cwd(), "src/styles.css")
103 | ],
104 | "test": /\.less$/,
105 | "loaders": [
106 | "exports-loader?module.exports.toString()",
107 | "css-loader?{\"sourceMap\":false,\"importLoaders\":1}",
108 | "postcss-loader",
109 | "less-loader"
110 | ]
111 | },
112 | {
113 | "exclude": [
114 | path.join(process.cwd(), "src/styles.css")
115 | ],
116 | "test": /\.styl$/,
117 | "loaders": [
118 | "exports-loader?module.exports.toString()",
119 | "css-loader?{\"sourceMap\":false,\"importLoaders\":1}",
120 | "postcss-loader",
121 | "stylus-loader?{\"sourceMap\":false,\"paths\":[]}"
122 | ]
123 | },
124 | {
125 | "include": [
126 | path.join(process.cwd(), "src/styles.css")
127 | ],
128 | "test": /\.css$/,
129 | "loaders": ExtractTextPlugin.extract({
130 | "use": [
131 | "css-loader?{\"sourceMap\":false,\"importLoaders\":1}",
132 | "postcss-loader"
133 | ],
134 | "fallback": "style-loader",
135 | "publicPath": ""
136 | })
137 | },
138 | {
139 | "include": [
140 | path.join(process.cwd(), "src/styles.css")
141 | ],
142 | "test": /\.scss$|\.sass$/,
143 | "loaders": ExtractTextPlugin.extract({
144 | "use": [
145 | "css-loader?{\"sourceMap\":false,\"importLoaders\":1}",
146 | "postcss-loader",
147 | "sass-loader"
148 | ],
149 | "fallback": "style-loader",
150 | "publicPath": ""
151 | })
152 | },
153 | {
154 | "include": [
155 | path.join(process.cwd(), "src/styles.css")
156 | ],
157 | "test": /\.less$/,
158 | "loaders": ExtractTextPlugin.extract({
159 | "use": [
160 | "css-loader?{\"sourceMap\":false,\"importLoaders\":1}",
161 | "postcss-loader",
162 | "less-loader"
163 | ],
164 | "fallback": "style-loader",
165 | "publicPath": ""
166 | })
167 | },
168 | {
169 | "include": [
170 | path.join(process.cwd(), "src/styles.css")
171 | ],
172 | "test": /\.styl$/,
173 | "loaders": ExtractTextPlugin.extract({
174 | "use": [
175 | "css-loader?{\"sourceMap\":false,\"importLoaders\":1}",
176 | "postcss-loader",
177 | "stylus-loader?{\"sourceMap\":false,\"paths\":[]}"
178 | ],
179 | "fallback": "style-loader",
180 | "publicPath": ""
181 | })
182 | },
183 | {
184 | "test": /\.ts$/,
185 | "loader": "@ngtools/webpack",
186 | "exclude": [
187 | /\.(spec|e2e)\.ts$/
188 | ]
189 | }
190 | ]
191 | },
192 | "plugins": [
193 | new NoEmitOnErrorsPlugin(),
194 | new HtmlWebpackPlugin({
195 | "template": "./src/index.html",
196 | "filename": "./index.html",
197 | "hash": false,
198 | "inject": true,
199 | "compile": true,
200 | "favicon": false,
201 | "minify": false,
202 | "cache": true,
203 | "showErrors": true,
204 | "chunks": "all",
205 | "excludeChunks": [],
206 | "title": "Webpack App",
207 | "xhtml": true,
208 | "chunksSortMode": function sort(left, right) {
209 | let leftIndex = entryPoints.indexOf(left.names[0]);
210 | let rightindex = entryPoints.indexOf(right.names[0]);
211 | if (leftIndex > rightindex) {
212 | return 1;
213 | }
214 | else if (leftIndex < rightindex) {
215 | return -1;
216 | }
217 | else {
218 | return 0;
219 | }
220 | }
221 | }),
222 | new BaseHrefWebpackPlugin({
223 | "baseHref": "/es/"
224 | }),
225 | new CommonsChunkPlugin({
226 | "name": "inline",
227 | "minChunks": null
228 | }),
229 | new CommonsChunkPlugin({
230 | "name": "vendor",
231 | "minChunks": (module) => module.resource && module.resource.startsWith(nodeModules),
232 | "chunks": [
233 | "main"
234 | ]
235 | }),
236 | new GlobCopyWebpackPlugin({
237 | "patterns": [
238 | "assets",
239 | "favicon.ico"
240 | ],
241 | "globOptions": {
242 | "cwd": "/home/philippe/Devs/MEDIUM/angular-cli-i18n-sample/src",
243 | "dot": true,
244 | "ignore": "**/.gitkeep"
245 | }
246 | }),
247 | new ProgressPlugin(),
248 | new ExtractTextPlugin({
249 | "filename": "[name].[contenthash:20].bundle.css",
250 | "disable": false
251 | }),
252 | new LoaderOptionsPlugin({
253 | "sourceMap": false,
254 | "options": {
255 | "postcss": [
256 | autoprefixer(),
257 | cssnano({ safe: true, autoprefixer: false })
258 | ],
259 | "sassLoader": {
260 | "sourceMap": false,
261 | "includePaths": []
262 | },
263 | "lessLoader": {
264 | "sourceMap": false
265 | },
266 | "context": ""
267 | }
268 | }),
269 | new SuppressExtractedTextChunksWebpackPlugin(),
270 | new DefinePlugin({
271 | "process.env.NODE_ENV": "\"production\""
272 | }),
273 | new UglifyJsPlugin({
274 | "mangle": {
275 | "screw_ie8": true
276 | },
277 | "compress": {
278 | "screw_ie8": true,
279 | "warnings": false
280 | },
281 | "sourceMap": false
282 | }),
283 | new AotPlugin({
284 | "tsConfigPath": "src/tsconfig.json",
285 | "mainPath": "main.ts",
286 | "i18nFile": "src/i18n/messages.es.xlf",
287 | "i18nFormat": "xlf",
288 | "locale": "es",
289 | "hostReplacementPaths": {
290 | "environments/environment.ts": "environments/environment.prod.ts"
291 | },
292 | "exclude": [
293 | "**/*.spec.ts",
294 | "test.ts"
295 | ]
296 | })
297 | ],
298 | "node": {
299 | "fs": "empty",
300 | "global": true,
301 | "crypto": "empty",
302 | "tls": "empty",
303 | "net": "empty",
304 | "process": true,
305 | "module": false,
306 | "clearImmediate": false,
307 | "setImmediate": false
308 | }
309 | };
310 |
--------------------------------------------------------------------------------
/webpack.fr.config.js:
--------------------------------------------------------------------------------
1 | const path = require('path');
2 | const HtmlWebpackPlugin = require('html-webpack-plugin');
3 | const ProgressPlugin = require('webpack/lib/ProgressPlugin');
4 | const ExtractTextPlugin = require('extract-text-webpack-plugin');
5 | const autoprefixer = require('autoprefixer');
6 | const cssnano = require('cssnano');
7 |
8 | const { NoEmitOnErrorsPlugin, LoaderOptionsPlugin, DefinePlugin } = require('webpack');
9 | const { BaseHrefWebpackPlugin, GlobCopyWebpackPlugin, SuppressExtractedTextChunksWebpackPlugin } = require('@angular/cli/plugins/webpack');
10 | const { CommonsChunkPlugin, UglifyJsPlugin } = require('webpack').optimize;
11 | const { AotPlugin } = require('@ngtools/webpack');
12 |
13 | const nodeModules = path.join(process.cwd(), 'node_modules');
14 | const entryPoints = ["inline","polyfills","sw-register","styles","vendor","main"];
15 |
16 |
17 |
18 |
19 | module.exports = {
20 | "devtool": false,
21 | "resolve": {
22 | "extensions": [
23 | ".ts",
24 | ".js"
25 | ],
26 | "modules": [
27 | "./node_modules"
28 | ]
29 | },
30 | "resolveLoader": {
31 | "modules": [
32 | "./node_modules"
33 | ]
34 | },
35 | "entry": {
36 | "main": [
37 | "./src/main.ts"
38 | ],
39 | "polyfills": [
40 | "./src/polyfills.ts"
41 | ],
42 | "styles": [
43 | "./src/styles.css"
44 | ]
45 | },
46 | "output": {
47 | "path": path.join(process.cwd(), "dist/fr"),
48 | "filename": "[name].[chunkhash:20].bundle.js",
49 | "chunkFilename": "[id].[chunkhash:20].chunk.js"
50 | },
51 | "module": {
52 | "rules": [
53 | {
54 | "enforce": "pre",
55 | "test": /\.js$/,
56 | "loader": "source-map-loader",
57 | "exclude": [
58 | /\/node_modules\//
59 | ]
60 | },
61 | {
62 | "test": /\.json$/,
63 | "loader": "json-loader"
64 | },
65 | {
66 | "test": /\.html$/,
67 | "loader": "raw-loader"
68 | },
69 | {
70 | "test": /\.(eot|svg)$/,
71 | "loader": "file-loader?name=[name].[hash:20].[ext]"
72 | },
73 | {
74 | "test": /\.(jpg|png|gif|otf|ttf|woff|woff2|cur|ani)$/,
75 | "loader": "url-loader?name=[name].[hash:20].[ext]&limit=10000"
76 | },
77 | {
78 | "exclude": [
79 | path.join(process.cwd(), "src/styles.css")
80 | ],
81 | "test": /\.css$/,
82 | "loaders": [
83 | "exports-loader?module.exports.toString()",
84 | "css-loader?{\"sourceMap\":false,\"importLoaders\":1}",
85 | "postcss-loader"
86 | ]
87 | },
88 | {
89 | "exclude": [
90 | path.join(process.cwd(), "src/styles.css")
91 | ],
92 | "test": /\.scss$|\.sass$/,
93 | "loaders": [
94 | "exports-loader?module.exports.toString()",
95 | "css-loader?{\"sourceMap\":false,\"importLoaders\":1}",
96 | "postcss-loader",
97 | "sass-loader"
98 | ]
99 | },
100 | {
101 | "exclude": [
102 | path.join(process.cwd(), "src/styles.css")
103 | ],
104 | "test": /\.less$/,
105 | "loaders": [
106 | "exports-loader?module.exports.toString()",
107 | "css-loader?{\"sourceMap\":false,\"importLoaders\":1}",
108 | "postcss-loader",
109 | "less-loader"
110 | ]
111 | },
112 | {
113 | "exclude": [
114 | path.join(process.cwd(), "src/styles.css")
115 | ],
116 | "test": /\.styl$/,
117 | "loaders": [
118 | "exports-loader?module.exports.toString()",
119 | "css-loader?{\"sourceMap\":false,\"importLoaders\":1}",
120 | "postcss-loader",
121 | "stylus-loader?{\"sourceMap\":false,\"paths\":[]}"
122 | ]
123 | },
124 | {
125 | "include": [
126 | path.join(process.cwd(), "src/styles.css")
127 | ],
128 | "test": /\.css$/,
129 | "loaders": ExtractTextPlugin.extract({
130 | "use": [
131 | "css-loader?{\"sourceMap\":false,\"importLoaders\":1}",
132 | "postcss-loader"
133 | ],
134 | "fallback": "style-loader",
135 | "publicPath": ""
136 | })
137 | },
138 | {
139 | "include": [
140 | path.join(process.cwd(), "src/styles.css")
141 | ],
142 | "test": /\.scss$|\.sass$/,
143 | "loaders": ExtractTextPlugin.extract({
144 | "use": [
145 | "css-loader?{\"sourceMap\":false,\"importLoaders\":1}",
146 | "postcss-loader",
147 | "sass-loader"
148 | ],
149 | "fallback": "style-loader",
150 | "publicPath": ""
151 | })
152 | },
153 | {
154 | "include": [
155 | path.join(process.cwd(), "src/styles.css")
156 | ],
157 | "test": /\.less$/,
158 | "loaders": ExtractTextPlugin.extract({
159 | "use": [
160 | "css-loader?{\"sourceMap\":false,\"importLoaders\":1}",
161 | "postcss-loader",
162 | "less-loader"
163 | ],
164 | "fallback": "style-loader",
165 | "publicPath": ""
166 | })
167 | },
168 | {
169 | "include": [
170 | path.join(process.cwd(), "src/styles.css")
171 | ],
172 | "test": /\.styl$/,
173 | "loaders": ExtractTextPlugin.extract({
174 | "use": [
175 | "css-loader?{\"sourceMap\":false,\"importLoaders\":1}",
176 | "postcss-loader",
177 | "stylus-loader?{\"sourceMap\":false,\"paths\":[]}"
178 | ],
179 | "fallback": "style-loader",
180 | "publicPath": ""
181 | })
182 | },
183 | {
184 | "test": /\.ts$/,
185 | "loader": "@ngtools/webpack",
186 | "exclude": [
187 | /\.(spec|e2e)\.ts$/
188 | ]
189 | }
190 | ]
191 | },
192 | "plugins": [
193 | new NoEmitOnErrorsPlugin(),
194 | new HtmlWebpackPlugin({
195 | "template": "./src/index.html",
196 | "filename": "./index.html",
197 | "hash": false,
198 | "inject": true,
199 | "compile": true,
200 | "favicon": false,
201 | "minify": false,
202 | "cache": true,
203 | "showErrors": true,
204 | "chunks": "all",
205 | "excludeChunks": [],
206 | "title": "Webpack App",
207 | "xhtml": true,
208 | "chunksSortMode": function sort(left, right) {
209 | let leftIndex = entryPoints.indexOf(left.names[0]);
210 | let rightindex = entryPoints.indexOf(right.names[0]);
211 | if (leftIndex > rightindex) {
212 | return 1;
213 | }
214 | else if (leftIndex < rightindex) {
215 | return -1;
216 | }
217 | else {
218 | return 0;
219 | }
220 | }
221 | }),
222 | new BaseHrefWebpackPlugin({
223 | "baseHref": "/fr/"
224 | }),
225 | new CommonsChunkPlugin({
226 | "name": "inline",
227 | "minChunks": null
228 | }),
229 | new CommonsChunkPlugin({
230 | "name": "vendor",
231 | "minChunks": (module) => module.resource && module.resource.startsWith(nodeModules),
232 | "chunks": [
233 | "main"
234 | ]
235 | }),
236 | new GlobCopyWebpackPlugin({
237 | "patterns": [
238 | "assets",
239 | "favicon.ico"
240 | ],
241 | "globOptions": {
242 | "cwd": "/home/philippe/Devs/MEDIUM/angular-cli-i18n-sample/src",
243 | "dot": true,
244 | "ignore": "**/.gitkeep"
245 | }
246 | }),
247 | new ProgressPlugin(),
248 | new ExtractTextPlugin({
249 | "filename": "[name].[contenthash:20].bundle.css",
250 | "disable": false
251 | }),
252 | new LoaderOptionsPlugin({
253 | "sourceMap": false,
254 | "options": {
255 | "postcss": [
256 | autoprefixer(),
257 | cssnano({ safe: true, autoprefixer: false })
258 | ],
259 | "sassLoader": {
260 | "sourceMap": false,
261 | "includePaths": []
262 | },
263 | "lessLoader": {
264 | "sourceMap": false
265 | },
266 | "context": ""
267 | }
268 | }),
269 | new SuppressExtractedTextChunksWebpackPlugin(),
270 | new DefinePlugin({
271 | "process.env.NODE_ENV": "\"production\""
272 | }),
273 | new UglifyJsPlugin({
274 | "mangle": {
275 | "screw_ie8": true
276 | },
277 | "compress": {
278 | "screw_ie8": true,
279 | "warnings": false
280 | },
281 | "sourceMap": false
282 | }),
283 | new AotPlugin({
284 | "tsConfigPath": "src/tsconfig.json",
285 | "mainPath": "main.ts",
286 | "i18nFile": "src/i18n/messages.fr.xlf",
287 | "i18nFormat": "xlf",
288 | "locale": "fr",
289 | "hostReplacementPaths": {
290 | "environments/environment.ts": "environments/environment.prod.ts"
291 | },
292 | "exclude": [
293 | "**/*.spec.ts",
294 | "test.ts"
295 | ]
296 | })
297 | ],
298 | "node": {
299 | "fs": "empty",
300 | "global": true,
301 | "crypto": "empty",
302 | "tls": "empty",
303 | "net": "empty",
304 | "process": true,
305 | "module": false,
306 | "clearImmediate": false,
307 | "setImmediate": false
308 | }
309 | };
310 |
--------------------------------------------------------------------------------