SHARE
TWEET

Untitled

a guest Jun 20th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module.exports = function (config) {
  2.   config.set({
  3.       basePath: '',
  4.       frameworks: ['jasmine'],
  5.       // list of files / patterns to load in the browser
  6.       files: [
  7.           './config/env.test.js',
  8.           { pattern: './spec-bundle.js', watched: false },
  9.       ],
  10.       preprocessors: {
  11.           './spec-bundle.js': ['webpack']
  12.       },
  13.       webpack: require('./webpack.config')({app: 'projectName', mode: 'test'}),
  14.  
  15.       webpackMiddleware: {
  16.           noInfo: true
  17.       },
  18.  
  19.       reporters: ['progress', 'coverage-istanbul'],
  20.       coverageIstanbulReporter: {
  21.  
  22.       reports: [ 'html', 'lcovonly'],
  23.       dir: 'coverage/',
  24.       fixWebpackSourcePaths: true,
  25.       combineBrowserReports: true,
  26.       skipFilesWithNoCoverage: true,
  27.       'report-config': {
  28.         html: {
  29.           subdir: 'html'
  30.         }
  31.       },
  32.       thresholds: {
  33.         emitWarning: false,
  34.         global: {
  35.           statements: 100,
  36.           lines: 100,
  37.           branches: 100,
  38.           functions: 100
  39.         }
  40.       }
  41.     },
  42.     port: 9876,
  43.     colors: true,
  44.     logLevel: config.LOG_INFO,
  45.     autoWatch: true,
  46.     browsers: [ 'Chrome'],
  47.     // browsers: [ 'PhantomJS'],
  48.     singleRun: false,
  49.     client: {
  50.       clearContext: false
  51.     },
  52.     concurrency: Infinity,
  53.     verbose: true
  54.   });
  55. }
  56.      
  57. require('core-js/es6');
  58. require('core-js/es7/reflect');
  59.  
  60. require('zone.js/dist/zone');
  61. require('zone.js/dist/long-stack-trace-zone');
  62. require('zone.js/dist/proxy');
  63. require('zone.js/dist/sync-test');
  64. require('zone.js/dist/jasmine-patch');
  65. require('zone.js/dist/async-test');
  66. require('zone.js/dist/fake-async-test');
  67. const testing = require('@angular/core/testing');
  68. const browser = require('@angular/platform-browser-dynamic/testing');
  69.  
  70. beforeAll(() => {
  71.     testing.TestBed.resetTestEnvironment();
  72.     testing.TestBed.initTestEnvironment(browser.BrowserDynamicTestingModule,
  73.       browser.platformBrowserDynamicTesting());
  74. });
  75.  
  76. const context = require.context("./src/test", true, /.spec.ts$/);
  77. context.keys().map(context);
  78.  
  79. function requireAll(requireContext) {
  80.     return requireContext.keys().map(requireContext);
  81. }
  82. const modules = requireAll(context)
  83.      
  84. const path = require('path');
  85. const helpers = require('./node.helpers.js');
  86. const CopyWebpackPlugin = require('copy-webpack-plugin');
  87. const ProgressPlugin = require('webpack/lib/ProgressPlugin');
  88. const CircularDependencyPlugin = require('circular-dependency-plugin');
  89. const HtmlWebpackPlugin = require('html-webpack-plugin');
  90.  
  91. const {
  92.   NoEmitOnErrorsPlugin,
  93.   SourceMapDevToolPlugin
  94. } = require('webpack');
  95. const {
  96.   NamedLazyChunksWebpackPlugin,
  97.   BaseHrefWebpackPlugin
  98. } = require('@angular/cli/plugins/webpack');
  99. const { AotPlugin } = require('@ngtools/webpack');
  100.  
  101. const entryPoints = [
  102.   'inline',
  103.   'polyfills',
  104.   'sw-register',
  105.   'styles',
  106.   'vendor',
  107.   'main'
  108. ];
  109.  
  110.  
  111. module.exports = function(environment) {
  112.   const tsConfig = environment.mode === 'test' ?  'src\tsconfig.spec.json' : 'src\tsconfig.app.json';
  113.   console.log('+++++++tsConfigPath++++++++++++',tsConfig);
  114.   var CONFIG = {
  115.     stats: 'errors-only',
  116.     resolve: {
  117.       extensions: ['.ts', '.js', '.scss'],
  118.       modules: ['./node_modules', './node_modules'],
  119.       symlinks: true
  120.     },
  121.     resolveLoader: {
  122.       modules: [
  123.         './node_modules',
  124.         './node_modules',
  125.         path.resolve(__dirname, 'loaders')
  126.       ]
  127.     },
  128.     entry: {
  129.       polyfills: ['./src/polyfills.ts']
  130.       //styles: ['./src/styles.css']
  131.     },
  132.     output: {
  133.       filename: '[name].bundle.js',
  134.       chunkFilename: '[id].chunk.js'
  135.     },
  136.     module: {
  137.       rules: [
  138.         {
  139.           enforce: 'pre',
  140.           test: /.js$/,
  141.           loader: 'source-map-loader',
  142.           exclude: [/(\|/)node_modules(\|/)/]
  143.         },
  144.         {
  145.           test: /.html$/,
  146.           loader: 'raw-loader'
  147.         },
  148.         {
  149.           test: /.(eot|svg|cur)$/,
  150.           loader: 'file-loader',
  151.           options: {
  152.             name: '[name].[hash:20].[ext]',
  153.             limit: 10000
  154.           }
  155.         },
  156.         {
  157.           test: /.(jpg|png|webp|gif|otf|ttf|woff|woff2|ani)$/,
  158.           loader: 'url-loader',
  159.           options: {
  160.             name: '[name].[hash:20]',
  161.             limit: 10000
  162.           }
  163.         },
  164.         {
  165.           test: /.[s]*css$/,
  166.           use: [
  167.             'style-loader',
  168.             'css-loader',
  169.             {
  170.               loader: 'postcss-loader',
  171.               options: {
  172.                 sourceMap: true,
  173.                 plugins: () => [require('autoprefixer')]
  174.               }
  175.             },
  176.             'resolve-url-loader',
  177.             'sass-loader?sourceMap',
  178.             {
  179.               loader: 'dls-loader',
  180.               options: require('./dls-config.json')
  181.             }
  182.           ]
  183.         },
  184.         {
  185.           test: /.ts$/,
  186.           loader: '@ngtools/webpack'
  187.         },
  188.         {
  189.           enforce: 'post',
  190.           test: /.(js|ts)$/,
  191.           loader: 'istanbul-instrumenter-loader',
  192.           query: {
  193.             esModules: true
  194.           },
  195.           include: helpers.root('src'),
  196.           exclude: [/.(e2e|spec).ts$/, /node_modules/]
  197.          }
  198.       ]
  199.     },
  200.     plugins: [
  201.       new NoEmitOnErrorsPlugin(),
  202.       new CopyWebpackPlugin(
  203.         [
  204.           {
  205.             context: 'src',
  206.             to: '',
  207.             from: {
  208.               glob: './assets/**/*',
  209.               dot: true
  210.             }
  211.           },
  212.           {
  213.             context: 'src',
  214.             to: '',
  215.             from: {
  216.               glob: './favicon.ico',
  217.               dot: true
  218.             }
  219.           }
  220.         ],
  221.         {
  222.           ignore: ['.gitkeep'],
  223.           debug: 'warning'
  224.         }
  225.       ),
  226.       new CopyWebpackPlugin([
  227.         {
  228.           from: `./config/env.${environment.mode}.js`,
  229.           to: './env.js',
  230.           toType: 'file'
  231.         },
  232.         {
  233.           from: './launcherClient/phoenixlauncher.js',
  234.           to: './phoenixlauncher.js',
  235.           toType: 'file'
  236.         },
  237.         {
  238.           from: './launcherClient/preLaunchingApp.html',
  239.           to: './preLaunchingApp.html',
  240.           toType: 'file'
  241.         },
  242.         {
  243.           from: './launcherClient/libs/jquery-3.3.1.min.js',
  244.           to: './libs/jquery-3.3.1.min.js',
  245.           toType: 'file'
  246.         },
  247.         {
  248.           from: './help/**/*',
  249.           to : './',
  250.         }
  251.       ]),
  252.       new ProgressPlugin(),
  253.       new CircularDependencyPlugin({
  254.         exclude: /(\|/)node_modules(\|/)/,
  255.         failOnError: false
  256.       }),
  257.       new NamedLazyChunksWebpackPlugin(),
  258.       new BaseHrefWebpackPlugin({}),
  259.       new SourceMapDevToolPlugin({
  260.         filename: '[file].map[query]',
  261.         moduleFilenameTemplate: '[resource-path]',
  262.         fallbackModuleFilenameTemplate: '[resource-path]?[hash]',
  263.         sourceRoot: 'webpack:///'
  264.       }),
  265.  
  266.     ],
  267.     node: {
  268.       fs: 'empty',
  269.       global: true,
  270.       crypto: 'empty',
  271.       tls: 'empty',
  272.       net: 'empty',
  273.       process: true,
  274.       module: false,
  275.       clearImmediate: false,
  276.       setImmediate: false
  277.     },
  278.     devServer: {
  279.       historyApiFallback: true
  280.     }
  281.   };
  282.   // Below configurations are separated because to ease th import of projectName app webpack conf to another webapack configuration.
  283.   CONFIG.entry.main = ['./src/projectName/main.ts'];
  284.   CONFIG.output.path = path.join(process.cwd(), '/dist/projectName');
  285.   CONFIG.plugins.push(
  286.     new HtmlWebpackPlugin({
  287.       template: './src/projectName/index.html',
  288.       filename: './index.html',
  289.       hash: false,
  290.       inject: true,
  291.       compile: true,
  292.       favicon: false,
  293.       minify: false,
  294.       cache: true,
  295.       showErrors: true,
  296.       chunks: 'all',
  297.       excludeChunks: [],
  298.       title: 'Webpack App',
  299.       xhtml: true,
  300.       chunksSortMode: function sort(left, right) {
  301.         let leftIndex = entryPoints.indexOf(left.names[0]);
  302.         let rightindex = entryPoints.indexOf(right.names[0]);
  303.         if (leftIndex > rightindex) {
  304.           return 1;
  305.         } else if (leftIndex < rightindex) {
  306.           return -1;
  307.         } else {
  308.           return 0;
  309.         }
  310.       }
  311.     })
  312.   );
  313.   CONFIG.plugins.push(
  314.     new AotPlugin({
  315.       mainPath: './projectName/main.ts',
  316.       replaceExport: false,
  317.       hostReplacementPaths: {
  318.         'environments\environment.ts': 'environments\environment.ts'
  319.       },
  320.       exclude: [],
  321.       tsConfigPath: tsConfig,
  322.       skipCodeGeneration: true
  323.     })
  324.   );
  325.   return CONFIG;
  326. };
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top