These are chat archives for AngularClass/angular2-webpack-starter

23rd
May 2017
Liyakhat Khan
@liyakhatalikhan
May 23 2017 03:13
spl @akankshagaur Where you able to figure out what was causing the issue of split undefined?
Liyakhat Khan
@liyakhatalikhan
May 23 2017 15:35

having issue with aot webpack angular4. Cannot read property split of undefined.

package.json

  "dependencies": {
    "@angular/common": "4.1.0",
    "@angular/compiler": "4.1.0",
    "@angular/compiler-cli": "4.1.0",
    "@angular/core": "4.1.0",
    "@angular/forms": "4.1.0",
    "@angular/http": "4.1.0",
    "@angular/platform-browser": "4.1.0",
    "@angular/platform-browser-dynamic": "4.1.0",
    "@angular/platform-server": "4.1.0",
    "@angular/router": "4.1.0",
    "@ng-bootstrap/ng-bootstrap": "1.0.0-alpha.25",
    "angular2-cookie": "1.2.6",
    "angular2-pipes": "^1.5.0",
    "angular2-wizard": "^0.3.0",
    "bootstrap": "4.0.0-alpha.6",
    "codelyzer": "^3.0.1",
    "core-js": "2.4.1",
    "express": "^4.15.3",
    "express-history-api-fallback": "^2.2.1",
    "font-awesome": "4.7.0",
    "http-proxy": "^1.16.2",
    "jquery": "3.2.1",
    "ng-jhipster": "0.1.12",
    "ng2-completer": "^1.4.0",
    "ng2-file-upload": "^1.2.1",
    "ng2-webstorage": "1.8.0",
    "ngx-infinite-scroll": "0.4.1",
    "ngx-pipes": "^1.5.10",
    "nodemon": "^1.11.0",
    "prerender-node": "^2.7.1",
    "reflect-metadata": "0.1.10",
    "rxjs": "5.3.0",
    "swagger-ui": "3.0.7",
    "tether": "1.4.0",
    "zone.js": "0.8.9"
  },
  "devDependencies": {
    "@angular/cli": "1.0.0",
    "@angular/compiler-cli": "4.1.0",
    "@types/jasmine": "2.5.47",
    "@types/node": "7.0.12",
    "add-asset-html-webpack-plugin": "2.0.1",
    "angular2-template-loader": "0.6.2",
    "awesome-typescript-loader": "3.1.2",
    "browser-sync": "2.18.8",
    "browser-sync-webpack-plugin": "1.1.4",
    "codelyzer": "3.0.1",
    "copy-webpack-plugin": "4.0.1",
    "css-loader": "0.28.0",
    "del": "2.2.2",
    "event-stream": "3.3.4",
    "exports-loader": "0.6.4",
    "extract-text-webpack-plugin": "2.1.0",
    "generator-jhipster": "4.3.0",
    "generator-jhipster-angular-

Webpack


const webpack = require('webpack');
//var CompressionPlugin = require("compression-webpack-plugin");
const commonConfig = require('./webpack.common.js');
const webpackMerge = require('webpack-merge');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const Visualizer = require('webpack-visualizer-plugin');
const path = require('path');
const ENV = 'prod';
const ngToolsWebpack = require('@ngtools/webpack');


module.exports = webpackMerge(commonConfig({ env: ENV }), {
    devtool: 'source-map',
    entry: {
        'polyfills': './src/main/webapp/app/polyfills',
        'global': './src/main/webapp/content/scss/global.scss',
        'main': './src/main/webapp/app/main-aot'
    },
    resolve: {
        extensions: ['.ts', '.js'],
        modules: ['node_modules']
    },
    output: {
        path: path.resolve('./target/aot'),
        filename: '[hash].[name].bundle.js',
        chunkFilename: '[hash].[id].chunk.js'
    },
    plugins: [
         new ngToolsWebpack.AotPlugin({
              tsConfigPath: './tsconfig-aot.json'
            }),
                new webpack.LoaderOptionsPlugin({
                    minimize: true,
                    debug: false
                }),
                /*new CompressionPlugin({
                    asset: "[path].gz[query]",
                    algorithm: "gzip",
                    test: /\.js$|\.html$/,
                    threshold: 10240,
                    minRatio: 0.8
                }),*/
                new webpack.optimize.UglifyJsPlugin({
                    compress: {
                        warnings: false
                    },
                    output: {
                        comments: false
                    },
                    sourceMap: true
                }),
        new ExtractTextPlugin('[hash].styles.css'),
        new Visualizer({
            // Webpack statistics in target folder
            filename: '../stats.html'
        })
    ],module: {
        loaders: [
            { test: /\.scss$/, loaders: ['raw-loader', 'sass-loader'] },
            { test: /\.css$/, loader: 'raw-loader' },
            { test: /\.html$/, loader: 'raw-loader' },
            { test: /\.ts$/, loaders: ['@ngtools/webpack', 'angular2-template-loader', 'awesome-typescript-loader'] }
          ]
        }
});