Guest User

Untitled

a guest
Feb 19th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.76 KB | None | 0 0
  1. const path = require('path');
  2. const ProgressPlugin = require('webpack/lib/ProgressPlugin');
  3. const HtmlWebpackPlugin = require('html-webpack-plugin');
  4. const ExtractTextPlugin = require('extract-text-webpack-plugin');
  5. const autoprefixer = require('autoprefixer');
  6. const postcssUrl = require('postcss-url');
  7. const cssnano = require('cssnano');
  8.  
  9. const { NoEmitOnErrorsPlugin, DefinePlugin, HashedModuleIdsPlugin } = require('webpack');
  10. const { GlobCopyWebpackPlugin, BaseHrefWebpackPlugin, SuppressExtractedTextChunksWebpackPlugin } = require('@angular/cli/plugins/webpack');
  11. const { CommonsChunkPlugin, UglifyJsPlugin } = require('webpack').optimize;
  12. const { AotPlugin } = require('@ngtools/webpack');
  13.  
  14. const nodeModules = path.join(process.cwd(), 'node_modules');
  15. const entryPoints = ["inline", "polyfills", "sw-register", "styles", "vendor", "main"];
  16. const minimizeCss = true;
  17. const baseHref = "/home";
  18. const deployUrl = "/app/uds";
  19. const postcssPlugins = function () {
  20. return [
  21. autoprefixer(),
  22. postcssUrl({
  23. url: (URL) => {
  24. // Only convert root relative URLs, which CSS-Loader won't process into require().
  25. if (!URL.startsWith('/') || URL.startsWith('//')) {
  26. return URL;
  27. }
  28. if (deployUrl.match(/:///)) {
  29. // If deployUrl contains a scheme, ignore baseHref use deployUrl as is.
  30. return `${deployUrl.replace(//$/, '')}${URL}`;
  31. }
  32. else if (baseHref.match(/:///)) {
  33. // If baseHref contains a scheme, include it as is.
  34. return baseHref.replace(//$/, '') +
  35. `/${deployUrl}/${URL}`.replace(///+/g, '/');
  36. }
  37. else {
  38. // Join together base-href, deploy-url and the original URL.
  39. // Also dedupe multiple slashes into single ones.
  40. return `/${baseHref}/${deployUrl}/${URL}`.replace(///+/g, '/');
  41. }
  42. }
  43. })
  44. ].concat(minimizeCss ? [cssnano({ safe: true, autoprefixer: false })] : []);
  45. };
  46.  
  47.  
  48.  
  49.  
  50. module.exports = {
  51. "devtool": "source-map",
  52. "resolve": {
  53. "extensions": [
  54. ".ts",
  55. ".js"
  56. ],
  57. "modules": [
  58. "./node_modules"
  59. ]
  60. },
  61. "resolveLoader": {
  62. "modules": [
  63. "./node_modules"
  64. ]
  65. },
  66. "entry": {
  67. "main": [
  68. path.join(process.cwd(), ".app/src/main.ts")
  69. ],
  70. "polyfills": [
  71. path.join(process.cwd(), ".app/src/polyfills.ts")
  72. ],
  73. "styles": [
  74. path.join(process.cwd(), ".app/src/styles.css")
  75. ]
  76. },
  77. "output": {
  78. "path": path.join(process.cwd(), "./dist/out"),
  79. "publicPath": "/app/uds",
  80. "filename": "[name].[chunkhash:20].bundle.js",
  81. "chunkFilename": "[id].[chunkhash:20].chunk.js"
  82. },
  83. "module": {
  84. "rules": [
  85. {
  86. "enforce": "pre",
  87. "test": /.js$/,
  88. "loader": "source-map-loader",
  89. "exclude": [
  90. //node_modules//
  91. ]
  92. },
  93. {
  94. "test": /.json$/,
  95. "loader": "json-loader"
  96. },
  97. {
  98. "test": /.html$/,
  99. "loader": "raw-loader"
  100. },
  101. {
  102. "test": /.(eot|svg)$/,
  103. "loader": "file-loader?name=[name].[hash:20].[ext]"
  104. },
  105. {
  106. "test": /.(jpg|png|gif|otf|ttf|woff|woff2|cur|ani)$/,
  107. "loader": "url-loader?name=[name].[hash:20].[ext]&limit=10000"
  108. },
  109. {
  110. "exclude": [
  111. const path = require('path')
  112.  
  113.  
  114.  
  115. ],
  116. "test": /.css$/,
  117. "use": [
  118. "exports-loader?module.exports.toString()",
  119. {
  120. "loader": "css-loader",
  121. "options": {
  122. "sourceMap": true,
  123. "importLoaders": 1
  124. }
  125. },
  126. {
  127. "loader": "postcss-loader",
  128. "options": {
  129. "ident": "postcss",
  130. "plugins": postcssPlugins
  131. }
  132. }
  133. ]
  134. },
  135. {
  136. "exclude": [
  137. const path = require('path')
  138.  
  139.  
  140.  
  141. ],
  142. "test": /.scss$|.sass$/,
  143. "use": [
  144. "exports-loader?module.exports.toString()",
  145. {
  146. "loader": "css-loader",
  147. "options": {
  148. "sourceMap": true,
  149. "importLoaders": 1
  150. }
  151. },
  152. {
  153. "loader": "postcss-loader",
  154. "options": {
  155. "ident": "postcss",
  156. "plugins": postcssPlugins
  157. }
  158. },
  159. {
  160. "loader": "sass-loader",
  161. "options": {
  162. "sourceMap": true,
  163. "precision": 8,
  164. "includePaths": []
  165. }
  166. }
  167. ]
  168. },
  169. {
  170. "exclude": [
  171. const path = require('path')
  172.  
  173.  
  174.  
  175. ],
  176. "test": /.less$/,
  177. "use": [
  178. "exports-loader?module.exports.toString()",
  179. {
  180. "loader": "css-loader",
  181. "options": {
  182. "sourceMap": true,
  183. "importLoaders": 1
  184. }
  185. },
  186. {
  187. "loader": "postcss-loader",
  188. "options": {
  189. "ident": "postcss",
  190. "plugins": postcssPlugins
  191. }
  192. },
  193. {
  194. "loader": "less-loader",
  195. "options": {
  196. "sourceMap": true
  197. }
  198. }
  199. ]
  200. },
  201. {
  202. "exclude": [
  203. const path = require('path')
  204.  
  205.  
  206.  
  207. ],
  208. "test": /.styl$/,
  209. "use": [
  210. "exports-loader?module.exports.toString()",
  211. {
  212. "loader": "css-loader",
  213. "options": {
  214. "sourceMap": true,
  215. "importLoaders": 1
  216. }
  217. },
  218. {
  219. "loader": "postcss-loader",
  220. "options": {
  221. "ident": "postcss",
  222. "plugins": postcssPlugins
  223. }
  224. },
  225. {
  226. "loader": "stylus-loader",
  227. "options": {
  228. "sourceMap": true,
  229. "paths": []
  230. }
  231. }
  232. ]
  233. },
  234. {
  235. "include": [
  236. const path = require('path')
  237.  
  238.  
  239.  
  240. ],
  241. "test": /.css$/,
  242. "loaders": ExtractTextPlugin.extract({
  243. "use": [
  244. {
  245. "loader": "css-loader",
  246. "options": {
  247. "sourceMap": true,
  248. "importLoaders": 1
  249. }
  250. },
  251. {
  252. "loader": "postcss-loader",
  253. "options": {
  254. "ident": "postcss",
  255. "plugins": postcssPlugins
  256. }
  257. }
  258. ],
  259. "fallback": "style-loader",
  260. "publicPath": ""
  261. })
  262. },
  263. {
  264. "include": [
  265. const path = require('path')
  266.  
  267.  
  268.  
  269. ],
  270. "test": /.scss$|.sass$/,
  271. "loaders": ExtractTextPlugin.extract({
  272. "use": [
  273. {
  274. "loader": "css-loader",
  275. "options": {
  276. "sourceMap": true,
  277. "importLoaders": 1
  278. }
  279. },
  280. {
  281. "loader": "postcss-loader",
  282. "options": {
  283. "ident": "postcss",
  284. "plugins": postcssPlugins
  285. }
  286. },
  287. {
  288. "loader": "sass-loader",
  289. "options": {
  290. "sourceMap": true,
  291. "precision": 8,
  292. "includePaths": []
  293. }
  294. }
  295. ],
  296. "fallback": "style-loader",
  297. "publicPath": ""
  298. })
  299. },
  300. {
  301. "include": [
  302. const path = require('path')
  303.  
  304.  
  305.  
  306. ],
  307. "test": /.less$/,
  308. "loaders": ExtractTextPlugin.extract({
  309. "use": [
  310. {
  311. "loader": "css-loader",
  312. "options": {
  313. "sourceMap": true,
  314. "importLoaders": 1
  315. }
  316. },
  317. {
  318. "loader": "postcss-loader",
  319. "options": {
  320. "ident": "postcss",
  321. "plugins": postcssPlugins
  322. }
  323. },
  324. {
  325. "loader": "less-loader",
  326. "options": {
  327. "sourceMap": true
  328. }
  329. }
  330. ],
  331. "fallback": "style-loader",
  332. "publicPath": ""
  333. })
  334. },
  335. {
  336. "include": [
  337. const path = require('path')
  338.  
  339.  
  340.  
  341. ],
  342. "test": /.styl$/,
  343. "loaders": ExtractTextPlugin.extract({
  344. "use": [
  345. {
  346. "loader": "css-loader",
  347. "options": {
  348. "sourceMap": true,
  349. "importLoaders": 1
  350. }
  351. },
  352. {
  353. "loader": "postcss-loader",
  354. "options": {
  355. "ident": "postcss",
  356. "plugins": postcssPlugins
  357. }
  358. },
  359. {
  360. "loader": "stylus-loader",
  361. "options": {
  362. "sourceMap": true,
  363. "paths": []
  364. }
  365. }
  366. ],
  367. "fallback": "style-loader",
  368. "publicPath": ""
  369. })
  370. },
  371. {
  372. "test": /.ts$/,
  373. "loader": "@ngtools/webpack"
  374. }
  375. ]
  376. },
  377. "plugins": [
  378. new NoEmitOnErrorsPlugin(),
  379. new GlobCopyWebpackPlugin({
  380. "patterns": [
  381. "assets"
  382. ],
  383. "globOptions": {
  384. "cwd": path.join(process.cwd(), "src/main/app/src/"),
  385. "dot": true,
  386. "ignore": "**/.gitkeep"
  387. }
  388. }),
  389. new ProgressPlugin(),
  390. new HtmlWebpackPlugin({
  391. "template": path.join(process.cwd(), "src/main/template.ftl"),
  392. "filename": path.join(process.cwd(), "dist/out/udsspa.ftl"),
  393. "hash": true,
  394. "inject": false,
  395. "compile": true,
  396. "favicon": false,
  397. "minify": false,
  398. "cache": true,
  399. "showErrors": true,
  400. "chunks": "all",
  401. "excludeChunks": [],
  402. "title": "Unified Deployment Systeme",
  403. "xhtml": true,
  404. "chunksSortMode": function sort(left, right) {
  405. let leftIndex = entryPoints.indexOf(left.names[0]);
  406. let rightindex = entryPoints.indexOf(right.names[0]);
  407. if (leftIndex > rightindex) {
  408. return 1;
  409. }
  410. else if (leftIndex < rightindex) {
  411. return -1;
  412. }
  413. else {
  414. return 0;
  415. }
  416. }
  417. }),
  418. new BaseHrefWebpackPlugin({
  419. "baseHref": "/home"
  420. }),
  421. new CommonsChunkPlugin({
  422. "name": "inline",
  423. "minChunks": null
  424. }),
  425. new CommonsChunkPlugin({
  426. "name": "vendor",
  427. "minChunks": (module) => module.resource && module.resource.startsWith(nodeModules),
  428. "chunks": [
  429. "main"
  430. ]
  431. }),
  432. new ExtractTextPlugin({
  433. "filename": "[name].[contenthash:20].bundle.css",
  434. "disable": false,
  435. "allChunks": true
  436. }),
  437. new SuppressExtractedTextChunksWebpackPlugin(),
  438. new DefinePlugin({
  439. "process.env.NODE_ENV": ""production""
  440. }),
  441. new HashedModuleIdsPlugin({
  442. "hashFunction": "md5",
  443. "hashDigest": "base64",
  444. "hashDigestLength": 4
  445. }),
  446. new UglifyJsPlugin({
  447. "mangle": {
  448. "screw_ie8": true
  449. },
  450. "compress": {
  451. "screw_ie8": true,
  452. "warnings": false
  453. },
  454. "sourceMap": true
  455. }),
  456. new AotPlugin({
  457. "mainPath": "main.ts",
  458. "hostReplacementPaths": {
  459. "environments/environment.ts": "environments/environment.prod.ts"
  460. },
  461. "exclude": [],
  462. "tsConfigPath": path.join(process.cwd(), ".app/src/tsconfig.app.json")
  463. })
  464. ],
  465. "node": {
  466. "fs": "empty",
  467. "global": true,
  468. "crypto": "empty",
  469. "tls": "empty",
  470. "net": "empty",
  471. "process": true,
  472. "module": false,
  473. "clearImmediate": false,
  474. "setImmediate": false
  475. },
  476. "devServer": {
  477. "historyApiFallback": true
  478. }
  479. };
  480.  
  481. <% for (key in htmlWebpackPlugin.files.js) { %>
  482. <script src="<@spring.url '<%= htmlWebpackPlugin.files.js[key].entry %>'/>" type="text/javascript"></script>
  483. <% } %>
  484. <% for (key in htmlWebpackPlugin.files.css) { %>
  485. <link href="<@spring.url '<%= htmlWebpackPlugin.files.css[key].entry %>'/>" rel="stylesheet" type="text/css"/></link>
  486. <% } %>
  487.  
  488. <script src="<@spring.url ''/>" type="text/javascript"></script>
  489. <script src="<@spring.url ''/>" type="text/javascript"></script>
  490. <script src="<@spring.url ''/>" type="text/javascript"></script>
  491. <script src="<@spring.url ''/>" type="text/javascript"></script>
  492. <script src="<@spring.url ''/>" type="text/javascript"></script>
  493. <link href="<@spring.url ''/>" rel="stylesheet" type="text/css"/></link>
  494.  
  495. <% for (key in htmlWebpackPlugin.files.chunks) { %>
  496. <script src="<@spring.url '<%= htmlWebpackPlugin.files.chunks[key].entry %>'/>" type="text/javascript"></script>
  497. <% } %>
  498.  
  499. <script src="<@spring.url '/app/inline.4cffe6e368f2c7d07127.bundle.js?532843813b34c259df54'/>" type="text/javascript"></script>
  500. <script src="<@spring.url '/app/polyfills.39a48f2e3268ad54bc6c.bundle.js?532843813b34c259df54'/>" type="text/javascript"></script>
  501. <script src="<@spring.url '/app/styles.49cb3bdd2d9987c8cbf2.bundle.css?532843813b34c259df54'/>" type="text/javascript"></script>
  502. <script src="<@spring.url '/app/vendor.1f6f6ff98fc2878385b4.bundle.js?532843813b34c259df54'/>" type="text/javascript"></script>
  503. <script src="<@spring.url '/app/uds/main.411bdc137897ab45279c.bundle.js?532843813b34c259df54'/>" type="text/javascript"></script>
Add Comment
Please, Sign In to add comment