django-webpack / webpack-bundle-tracker

Spits out some stats about webpack compilation process to a file
MIT License
266 stars 107 forks source link

1.0.0-alpha.1 version not generating webpack-stats.json file #80

Closed pwhipp closed 3 years ago

pwhipp commented 3 years ago

If I change back to 0.4.3, it works fine.

const webpack = require('webpack');
const BundleTracker = require('webpack-bundle-tracker');

const config = require('./base.js');

// Use webpack dev server
config.mode = 'development';

config.devServer = {
    disableHostCheck: true,
    contentBase: '../assets/bundles/',
    compress: true,
    publicPath: 'http://0.0.0.0:3000/assets/bundles/',
    port: 3000,
    headers: {
            'Access-Control-Allow-Origin': '*'}}

config.plugins = config.plugins.concat([
  new BundleTracker({filename: 'webpack-stats.json'})]);

module.exports = config;
ceasaro commented 3 years ago

I had a similar issue but my generated webpack-stats.json had a different format. I'm not familiar with the new format and maybe it's correct for a newer version but in my cause it failed. I't looks like it's generating a webpack-stats.json for the production environment?

In 0.4.3 a get:

{
  "status": "done",
  "publicPath": "http://localhost:3000/",
  "chunks": {
    "main": [
      {
        "name": "main.js",
        "publicPath": "http://localhost:3000/main.js",
        "path": ".../static/main.js"
      }
    ]
  }
}

But in 1.0.0-alpha.1 I get:

{
  "status": "done",
  "chunks": {
    "main": [
      "main.js"
    ]
  },
  "publicPath": "http://localhost:3000/",
  "assets": {
    "b84894866db13a05ea7a17ecd0119cc7.png": {
      "name": "b84894866db13a05ea7a17ecd0119cc7.png",
      "publicPath": "http://localhost:3000/b84894866db13a05ea7a17ecd0119cc7.png"
    },
    "a8950e6e4cb9b3d8b891613f9fc6e8ff.png": {
      "name": "a8950e6e4cb9b3d8b891613f9fc6e8ff.png",
      "publicPath": "http://localhost:3000/a8950e6e4cb9b3d8b891613f9fc6e8ff.png"
    },
    "c31bde4f06869843bacd10ad5983553c.png": {
      "name": "c31bde4f06869843bacd10ad5983553c.png",
      "publicPath": "http://localhost:3000/c31bde4f06869843bacd10ad5983553c.png"
    },
    "f21d0f48ce2269e5d4b48f2a9e8bab02.png": {
      "name": "f21d0f48ce2269e5d4b48f2a9e8bab02.png",
      "publicPath": "http://localhost:3000/f21d0f48ce2269e5d4b48f2a9e8bab02.png"
    },
    "288184c987475814c1ac6ffa03cb501b.png": {
      "name": "288184c987475814c1ac6ffa03cb501b.png",
      "publicPath": "http://localhost:3000/288184c987475814c1ac6ffa03cb501b.png"
    },
    "517a52cd15144babcde450b945dcb232.png": {
      "name": "517a52cd15144babcde450b945dcb232.png",
      "publicPath": "http://localhost:3000/517a52cd15144babcde450b945dcb232.png"
    },
    "318c31fcd82ef166296d3e036c17adb1.png": {
      "name": "318c31fcd82ef166296d3e036c17adb1.png",
      "publicPath": "http://localhost:3000/318c31fcd82ef166296d3e036c17adb1.png"
    },
    "545ef5c29d8d70c519a682f018ede88d.png": {
      "name": "545ef5c29d8d70c519a682f018ede88d.png",
      "publicPath": "http://localhost:3000/545ef5c29d8d70c519a682f018ede88d.png"
    },
    "0da8a5258ba74cb39d48578dcbf799ca.png": {
      "name": "0da8a5258ba74cb39d48578dcbf799ca.png",
      "publicPath": "http://localhost:3000/0da8a5258ba74cb39d48578dcbf799ca.png"
    },
    "f94fb4f44c48e1ec8c60f39f38ae51e0.png": {
      "name": "f94fb4f44c48e1ec8c60f39f38ae51e0.png",
      "publicPath": "http://localhost:3000/f94fb4f44c48e1ec8c60f39f38ae51e0.png"
    },
    "c7d633ce4d7098e24ae4b9151eba7876.png": {
      "name": "c7d633ce4d7098e24ae4b9151eba7876.png",
      "publicPath": "http://localhost:3000/c7d633ce4d7098e24ae4b9151eba7876.png"
    },
    "0d20484224616ead096d74c84b38e08f.png": {
      "name": "0d20484224616ead096d74c84b38e08f.png",
      "publicPath": "http://localhost:3000/0d20484224616ead096d74c84b38e08f.png"
    },
    "0abe63dc922d9119b80f896e80368cf6.png": {
      "name": "0abe63dc922d9119b80f896e80368cf6.png",
      "publicPath": "http://localhost:3000/0abe63dc922d9119b80f896e80368cf6.png"
    },
    "b245566796e12b2f08b4625bfab07a66.png": {
      "name": "b245566796e12b2f08b4625bfab07a66.png",
      "publicPath": "http://localhost:3000/b245566796e12b2f08b4625bfab07a66.png"
    },
    "13978bb2b0deb4a2725a5719a8d10aee.png": {
      "name": "13978bb2b0deb4a2725a5719a8d10aee.png",
      "publicPath": "http://localhost:3000/13978bb2b0deb4a2725a5719a8d10aee.png"
    },
    "3bc44947ab8eb26df6e50cf6acbd4958.png": {
      "name": "3bc44947ab8eb26df6e50cf6acbd4958.png",
      "publicPath": "http://localhost:3000/3bc44947ab8eb26df6e50cf6acbd4958.png"
    },
    "0c2a39417c1249032405da0ab62debe2.png": {
      "name": "0c2a39417c1249032405da0ab62debe2.png",
      "publicPath": "http://localhost:3000/0c2a39417c1249032405da0ab62debe2.png"
    },
    "main.js": {
      "name": "main.js",
      "publicPath": "http://localhost:3000/main.js"
    }
  }
}
maddogcz commented 3 years ago

webpack-stats.json IS being generated BUT for some reason the path is relative to 'outputDir' (al least for me) instead to NPM base dir. I suppose the new format is meant for automatic retrieval of dependencies, but'Il have to write some custom loader for it.

blafasel42 commented 3 years ago

i had the same issue. needd to add path to tracker parameters, then it worked. so instead of:

  config
        .plugin("BundleTracker")
        .use(BundleTracker, [{ filename: "../webpack-stats.json" }]);

i now use:

  config
        .plugin("BundleTracker")
        .use(BundleTracker, [{ path: "../", filename: "webpack-stats.json" }]);

and file is written. Unfortunately, output of 1-alpha.1 can still not be read by django-webpack-loader. Any help would be appreciated here.