Custom webpack.config.js not generating Vendor.js


#1

I Get net::ERR_FILE_NOT_FOUND for vendor.js in the browser.

I have a custom webpack.config.js as follows (BEcause it is a desktop app with Electron):


var path = require('path');
var webpack = require('webpack');
var ionicWebpackFactory = require(process.env.IONIC_WEBPACK_FACTORY);
module.exports = {
  entry: process.env.IONIC_APP_ENTRY_POINT,
  output: {
    path: '{{BUILD}}',
    publicPath: 'build/',
    filename: process.env.IONIC_OUTPUT_JS_FILE_NAME,
    devtoolModuleFilenameTemplate: ionicWebpackFactory.getSourceMapperFunction(),
  },
  externals: [
    (function () {
        var IGNORES = ["fs","child_process","electron","path","assert","cluster","crypto","dns","domain","events","http","https","net","os","process","punycode","querystring","readline","repl","stream","string_decoder","tls","tty","dgram","url","util","v8","vm","zlib"];
        return function (context, request, callback) {
            if (IGNORES.indexOf(request) >= 0) {
                return callback(null, "require('" + request + "')");
            }
            return callback();
        };
    })()
  ],
  devtool: process.env.IONIC_SOURCE_MAP_TYPE,
  resolve: {
    extensions: ['.ts', '.js', '.json'],
    modules: [path.resolve('node_modules')]
  },
  module: {
    loaders: [
      {
        test: /\.json$/,
        loader: 'json-loader'
      },
      {
        test: /\.ts$/,
        loader: process.env.IONIC_WEBPACK_LOADER
      }
    ]
  },
  plugins: [
    ionicWebpackFactory.getIonicEnvironmentPlugin(),
  ],
  // Some libraries import Node modules but don't use them in the browser.
  // Tell Webpack to provide empty mocks for them so importing them works.
  node: {
    fs: 'empty',
    net: 'empty',
    tls: 'empty'
  }
};

and, in my package.json

{
  "name": "myApp",
  "version": "0.99.9",
  "author": {
    "name": "myname",
    "email": "dfdf@dfdf.com",
    "url": "https://dfdf.com"
  },
  "homepage": "http://dfdf.com",
  "private": true,
  "main": "electron/electron.js",
  "config": {
    "ionic_bundler": "webpack",
    "ionic_webpack": "./config/webpack.config.js"
  },
  "scripts": {
    "dev": "nf start",
    "start": "ionic-app-scripts serve",
    "electron dist": "electron .",
    "ebuild": "npm run build && node_modules/.bin/build",
    "clean": "ionic-app-scripts clean",
    "build": "ionic-app-scripts build",
    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "ionic-app-scripts serve"
  },
  "build": {
    "appId": "com.dfdf.dfdf",
    "electronVersion": "1.7.8",
    "asar": false,
    "files": [
      "www/**/*",
      "electron/*"
    ]
  },
  "dependencies": {
    "@angular/common": "4.1.3",
    "@angular/compiler": "4.1.3",
    "@angular/compiler-cli": "4.1.3",
    "@angular/core": "4.1.3",
    "@angular/forms": "4.1.3",
    "@angular/http": "4.1.3",
    "@angular/platform-browser": "4.1.3",
    "@angular/platform-browser-dynamic": "4.1.3",
    "@ionic-native/core": "3.12.1",
    "@ionic-native/splash-screen": "3.12.1",
    "@ionic-native/status-bar": "3.12.1",
    "@ionic/storage": "2.0.1",
    "@types/gsap": "^1.19.1",
    "gsap": "^1.20.2",
    "ionic-angular": "3.6.1",
    "ionicons": "3.0.0",
    "rxjs": "5.4.0",
    "sw-toolbox": "3.6.0",
    "zone.js": "0.8.12"
  },
  "devDependencies": {
    "@ionic/app-scripts": "2.1.4",
    "electron": "^1.7.8",
    "electron-builder": "^19.31.1",
    "foreman": "^2.0.0",
    "typescript": "2.3.4"
  },
  "description": "descr"
}

Any ideas why this is failing to generate the vendor.js?

Thanks!


#2

Hi, I’m facing the same issue, did you find the answer?


#3

Hi,

Do you have a <base href="./"> in your index.html

Have you tried publicPath: 'build/' -> publicPath: './build/'

Do you get the error if you run things manually? E.g., run the following commands (they must be run in separate terminal sessions as ionic serve is blocking)

ionic serve --no-open
electron .

See:

Cheers
Rob