Advertisement
Guest User

Webpack config sample : Stackoverflow question

a guest
May 18th, 2018
714
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. This configuration is part of : https://stackoverflow.com/questions/50405930/aot-angular-6-directive-somecomponent-expected-0-arguments-but-got-1-for
  2.  
  3. My extracted configuration :  
  4. *Section rules and loader*
  5.  
  6.     rules: [
  7.         /**
  8.          * Compiles TypeScript files.
  9.          */
  10.         {
  11.             test: /\.tsx?$/,
  12.             use: [{
  13.                     loader: 'babel-loader'
  14.                 },
  15.                 {
  16.                     loader: '@ngtools/webpack'
  17.                 }
  18.             ]
  19.         }
  20.     ]
  21.  
  22. *Section plugins*
  23.  
  24.     [
  25.         new AngularCompilerPlugin(
  26.         {
  27.             tsConfigPath: ROOT + '/tsconfig.json',
  28.             entryModule: ROOT + '/path/to/app.module/#AppModule'
  29.         }),
  30.         /**
  31.          * Webpack plugin to optimize a JavaScript file for faster initial load
  32.          * by wrapping eagerly-invoked functions.
  33.          *
  34.          * See: https://github.com/vigneshshanmugam/optimize-js-plugin
  35.          */
  36.         new OptimizeJsPlugin(
  37.         {
  38.             sourceMap: false
  39.         }),
  40.         /**
  41.          * Minify all javascript, switch loaders to minimizing mode
  42.          * Reference: https://webpack.js.org/plugins/uglifyjs-webpack-plugin/
  43.          */
  44.         new UglifyJsPlugin(
  45.         {
  46.             cache: true,
  47.             parallel: true,
  48.             uglifyOptions:
  49.             {
  50.                 ecma: 5,
  51.                 mangle: true,
  52.                 keep_classnames: true,
  53.                 compress:
  54.                 {
  55.                     drop_console: true,
  56.                     warnings: false,
  57.                     conditionals: true,
  58.                     unused: true,
  59.                     comparisons: true,
  60.                     sequences: true,
  61.                     dead_code: true,
  62.                     evaluate: true,
  63.                     if_return: true,
  64.                     join_vars: true,
  65.                     negate_iife: false // we need this for lazy v8
  66.                 }
  67.             },
  68.         }),
  69.         /**
  70.          * Plugin: NormalModuleReplacementPlugin
  71.          * Description: Replace resources that matches resourceRegExp with newResource
  72.          *
  73.          * See: http://webpack.github.io/docs/list-of-plugins.html#normalmodulereplacementplugin
  74.          */
  75.         new NormalModuleReplacementPlugin(
  76.             /angular2-hmr/,
  77.             '@ngApp/empty.js'
  78.         ),
  79.         new NormalModuleReplacementPlugin(
  80.             /zone\.js(\\|\/)dist(\\|\/)long-stack-trace-zone/,
  81.         '@ngApp/empty.js'
  82.     ),
  83.     ]
  84.  
  85. *section tsconfig.json*
  86.  
  87.     {
  88.       "exclude": [
  89.         "node_modules",
  90.         "vendor"
  91.       ],
  92.       "include": [
  93.         "src",
  94.         "node_modules/@nicky-lenaers/ngx-scroll-to"
  95.       ],
  96.       "compileOnSave": false,
  97.       "compilerOptions": {
  98.         "sourceMap": true,
  99.         "declaration": false,
  100.         "moduleResolution": "node",
  101.         "emitDecoratorMetadata": true,
  102.         "experimentalDecorators": true,
  103.         "noImplicitAny": true,
  104.         "suppressImplicitAnyIndexErrors": true,
  105.         "allowSyntheticDefaultImports": true,
  106.         "target": "es2015",
  107.         "types": ["node","velocity-animate"],
  108.         "typeRoots": [
  109.           "node_modules/@types"
  110.         ]
  111.       },
  112.       "angularCompilerOptions": {
  113.         "fullTemplateTypeCheck": true,
  114.         "preserveWhitespaces": true
  115.       },
  116.       "awesomeTypescriptLoaderOptions": {
  117.         "forkChecker": true,
  118.         "useWebpackText": true
  119.       }
  120.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement