Guest User

Untitled

a guest
Jun 22nd, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.47 KB | None | 0 0
  1. package.json:
  2. {
  3. "name": "test",
  4. "version": "1.0.0",
  5. "scripts": {
  6. "start": "node_modules/.bin/webpack --progress"
  7. },
  8. "devDependencies": {
  9. "@ngtools/webpack": "^6.0.8",
  10. "css-loader": "^0.28.11",
  11. "html-webpack-plugin": "^3.2.0",
  12. "mini-css-extract-plugin": "^0.4.0",
  13. "raw-loader": "^0.5.1",
  14. "typescript": "^2.7.2",
  15. "webpack": "^4.12.0",
  16. "webpack-cli": "^3.0.8"
  17. },
  18. "dependencies": {
  19. "@angular/common": "^6.0.6",
  20. "@angular/compiler": "^6.0.6",
  21. "@angular/compiler-cli": "^6.0.6",
  22. "@angular/core": "^6.0.6",
  23. "@angular/platform-browser": "^6.0.6",
  24. "@angular/platform-browser-dynamic": "^6.0.6"
  25. }
  26. }
  27.  
  28. ---------------------------------------------------------------------------
  29.  
  30. tsconfig.json:
  31. {
  32. "compilerOptions": {
  33. "target": "es6",
  34. "sourceMap": true,
  35. "module": "commonjs",
  36. "experimentalDecorators": true,
  37. "emitDecoratorMetadata": true,
  38. "outDir": "app",
  39. },
  40. "exclude": [
  41. "node_modules"
  42. ],
  43. "lib": [
  44. "dom",
  45. "es2015"
  46. ],
  47. "angularCompilerOptions": {
  48. "fullTemplateTypeCheck": true,
  49. "preserveWhitespaces": true
  50. }
  51. }
  52.  
  53. ---------------------------------------------------------------------------
  54. webpack.config.js:
  55. const HtmlWebpackPlugin = require("html-webpack-plugin");
  56. const { AngularCompilerPlugin } = require("@ngtools/webpack");
  57. const MiniCssExtractPlugin = require("mini-css-extract-plugin");
  58.  
  59. module.exports = () => {
  60. return {
  61. entry: "./src/main.ts",
  62. output: {
  63. path: __dirname + "/application",
  64. filename: "app.js"
  65. },
  66. resolve: {
  67. extensions: [".ts", ".js"]
  68. },
  69. mode: "production",
  70. module: {
  71. rules: [
  72. {
  73. test: /(?:\.ngfactory\.js|\.ngstyle\.js|\.ts)$/,
  74. loader: "@ngtools/webpack"
  75. },
  76. {
  77. test: /\.html$/,
  78. loader: "raw-loader"
  79. },
  80. {
  81. test: /\.css$/,
  82. use: [
  83. MiniCssExtractPlugin.loader,
  84. "css-loader"
  85. ]
  86. }
  87. ]
  88. },
  89. plugins: [
  90. new HtmlWebpackPlugin({
  91. template: __dirname + "/src/index.html",
  92. output: __dirname + "/dist",
  93. inject: "head",
  94. hash: true
  95. }),
  96. new MiniCssExtractPlugin({
  97. filename: "[name].css"
  98. }),
  99. new AngularCompilerPlugin({
  100. tsConfigPath: "./tsconfig.json",
  101. entryModule: __dirname + "/src/application/application.module#ApplicationModule",
  102. skipCodeGeneration: false
  103. })
  104. ]
  105. };
  106. }
  107.  
  108. ---------------------------------------------------------------------------
  109. src/index.html:
  110. <html>
  111. <head>
  112. <title>App</title>
  113. </head>
  114. <body>
  115. <app></app>
  116. </body>
  117. </html>
  118.  
  119. ---------------------------------------------------------------------------
  120.  
  121. src/main.ts:
  122. import { enableProdMode } from "@angular/core";
  123. import { platformBrowserDynamic } from "@angular/platform-browser-dynamic";
  124. import { ApplicationModule } from "./application/application.module";
  125. enableProdMode();
  126. platformBrowserDynamic().bootstrapModule(ApplicationModule);
  127.  
  128. ---------------------------------------------------------------------------
  129.  
  130. src/styles/style.css:
  131. body, html {
  132. height: 100%;
  133. width: 100%;
  134. }
  135.  
  136. ---------------------------------------------------------------------------
  137.  
  138. src/application/application.component.html:
  139. Test
  140.  
  141. ---------------------------------------------------------------------------
  142.  
  143. src/application/application.component.ts:
  144. import { Component } from "@angular/core";
  145.  
  146. @Component({
  147. selector: "app",
  148. templateUrl: "./application.component.html",
  149. styleUrls: ["../styles/style.css"],
  150. })
  151.  
  152. export class ApplicationComponent {
  153. }
  154.  
  155. ---------------------------------------------------------------------------
  156.  
  157. src/application/application.module.ts:
  158. import { NgModule } from "@angular/core";
  159. import { BrowserModule } from "@angular/platform-browser"
  160. import { ApplicationComponent } from "./application.component";
  161.  
  162. @NgModule({
  163. imports: [BrowserModule],
  164. declarations: [
  165. ApplicationComponent,
  166. ],
  167. bootstrap: [ApplicationComponent]
  168. })
  169.  
  170. export class ApplicationModule {
  171. }
  172.  
  173. ---------------------------------------------------------------------------
Add Comment
Please, Sign In to add comment