|
| 1 | +const fs = require('fs'); |
| 2 | +const path = require('path'); |
| 3 | +const CopyWebpackPlugin = require('copy-webpack-plugin'); |
| 4 | +const ProgressPlugin = require('webpack/lib/ProgressPlugin'); |
| 5 | +const CircularDependencyPlugin = require('circular-dependency-plugin'); |
| 6 | +const rxPaths = require('rxjs/_esm5/path-mapping'); |
| 7 | + |
| 8 | +const { NoEmitOnErrorsPlugin } = require('webpack'); |
| 9 | +const { BaseHrefWebpackPlugin } = require('@angular/cli/plugins/webpack'); |
| 10 | +const { CommonsChunkPlugin } = require('webpack').optimize; |
| 11 | + |
| 12 | +const nodeModules = path.join(process.cwd(), 'node_modules'); |
| 13 | +const realNodeModules = fs.realpathSync(nodeModules); |
| 14 | +const genDirNodeModules = path.join(process.cwd(), 'src', '$$_gendir', 'node_modules'); |
| 15 | + |
| 16 | +const projectRoot = process.cwd(); |
| 17 | + |
| 18 | +module.exports = { |
| 19 | + "resolve": { |
| 20 | + "extensions": [ |
| 21 | + ".ts", |
| 22 | + ".js" |
| 23 | + ], |
| 24 | + "symlinks": true, |
| 25 | + "modules": [ |
| 26 | + "./src", |
| 27 | + "./node_modules" |
| 28 | + ] |
| 29 | + }, |
| 30 | + "resolveLoader": { |
| 31 | + "modules": [ |
| 32 | + "./node_modules" |
| 33 | + ], |
| 34 | + "alias": rxPaths() |
| 35 | + }, |
| 36 | + "module": { |
| 37 | + "rules": [ |
| 38 | + { |
| 39 | + "test": /\.html$/, |
| 40 | + "loader": "raw-loader" |
| 41 | + }, |
| 42 | + { |
| 43 | + "test": /\.(eot|svg|cur)$/, |
| 44 | + "loader": "file-loader", |
| 45 | + "options": { |
| 46 | + "name": "[name].[hash:20].[ext]", |
| 47 | + "limit": 10000 |
| 48 | + } |
| 49 | + }, |
| 50 | + { |
| 51 | + "test": /\.(jpg|png|webp|gif|otf|ttf|woff|woff2|ani)$/, |
| 52 | + "loader": "url-loader", |
| 53 | + "options": { |
| 54 | + "name": "[name].[hash:20].[ext]", |
| 55 | + "limit": 10000 |
| 56 | + } |
| 57 | + }, |
| 58 | + { |
| 59 | + "test": /\.ts$/, |
| 60 | + "loader": "@ngtools/webpack" |
| 61 | + } |
| 62 | + ] |
| 63 | + }, |
| 64 | + "plugins": [ |
| 65 | + new NoEmitOnErrorsPlugin(), |
| 66 | + new CopyWebpackPlugin([ |
| 67 | + { |
| 68 | + "context": "src", |
| 69 | + "to": "", |
| 70 | + "from": { |
| 71 | + "glob": "assets\\**\\*", |
| 72 | + "dot": true |
| 73 | + } |
| 74 | + }, |
| 75 | + { |
| 76 | + "context": "src", |
| 77 | + "to": "", |
| 78 | + "from": { |
| 79 | + "glob": "favicon.ico", |
| 80 | + "dot": true |
| 81 | + } |
| 82 | + } |
| 83 | + ], { |
| 84 | + "ignore": [ |
| 85 | + ".gitkeep", |
| 86 | + "**/.DS_Store", |
| 87 | + "**/Thumbs.db" |
| 88 | + ], |
| 89 | + "debug": "warning" |
| 90 | + }), |
| 91 | + new ProgressPlugin(), |
| 92 | + new CircularDependencyPlugin({ |
| 93 | + "exclude": /(\\|\/)node_modules(\\|\/)/, |
| 94 | + "failOnError": false, |
| 95 | + "onDetected": false, |
| 96 | + "cwd": projectRoot |
| 97 | + }), |
| 98 | + new BaseHrefWebpackPlugin({}), |
| 99 | + new CommonsChunkPlugin({ |
| 100 | + "name": [ |
| 101 | + "inline" |
| 102 | + ], |
| 103 | + "minChunks": null |
| 104 | + }), |
| 105 | + new CommonsChunkPlugin({ |
| 106 | + "name": [ |
| 107 | + "main" |
| 108 | + ], |
| 109 | + "minChunks": 2, |
| 110 | + "async": "common" |
| 111 | + }) |
| 112 | + ], |
| 113 | + "node": { |
| 114 | + "fs": "empty", |
| 115 | + "global": true, |
| 116 | + "crypto": "empty", |
| 117 | + "tls": "empty", |
| 118 | + "net": "empty", |
| 119 | + "process": true, |
| 120 | + "module": false, |
| 121 | + "clearImmediate": false, |
| 122 | + "setImmediate": false |
| 123 | + }, |
| 124 | + "devServer": { |
| 125 | + "historyApiFallback": true |
| 126 | + } |
| 127 | +}; |
0 commit comments