markshapiro/webpack-merge-and-include-globally

New Asset(s) Do Not Gets Updated in Webpack Stats

gdad-s-river opened this issue · 4 comments

The new file gets generated fine and gets served well ( over local dev server ). But the file does not seem to get updated in the webpack stats in the assets. I check this using assets-webpack-plugin.

I googled around if it was a webpack thingy, but couldn't pin point. Perhaps someone could help?

@markshapiro

do you mean the file names don't get updated if changed? what do you store with stats file?

This happened — 

I used webpack-merge-and-include-globally and saw in my console of webpack that my new file has been generated (yeahScience.js)

screen shot 2018-11-15 at 3 34 29 pm

But when I use assets-webpack-plugin to see if it has been added by the webpack in the webpack graph, it hasn't been added — 

screen shot 2018-11-15 at 3 36 28 pm

I'm dependent on the bundle generated by webpack-merge-and-include-globally being added to webpack graph this way — 

  • the project I'm working for is using webpack-isomorphic-tools

  • The project uses webpackIsomorphic.assets() to dynamically access generated bundle file's name in an express handler js file, which is intended to be served for a particular route. Hence I need the generated file to added to the webpack graph.

Makes sense?

I tried a bare bones webpack setup to check this.

// src/1.js
const a = 'a';

// src/2.js
const b = 'b';

// src/index.js
const index = 'index'
// package.json
{
  "name": "webpack-concat-plugin-webpack-1-test",
  "version": "1.0.0",
  "description": "",
  "main": "src/index.js",
  "dependencies": {
    "webpack": "^1.15.0",
    "webpack-dev-server": "^3.1.10"
  },
  "devDependencies": {
    "assets-webpack-plugin": "^3.9.7",
    "webpack-merge-and-include-globally": "^2.1.5"
  },
  "scripts": {
    "build": "webpack"
  },
  "author": "",
  "license": "ISC"
}
// webpack.config.js

const AssetsPlugin = require('assets-webpack-plugin');
const MergeIntoSingleFilePlugin = require('webpack-merge-and-include-globally');

var assetsPluginInstance = new AssetsPlugin();

module.exports = {
  entry: './src/index.js',
  output: {
    filename: './bundle.js'
  },
  plugins: [
    new AddAssetPlugin('file.js', `

    new MergeIntoSingleFilePlugin({
      files: {
        'yeahScienceMath.js': [
          './src/*.js'
        ],
      },
    }),
    assetsPluginInstance
  ]
};

on running webpack webpack-assets.json comes out to be :

{"main":{"js":"./bundle.js"},"":{"js":["yeahScienceMath.js"]}}

I have no idea why it isn't working in my project 😅

does AddAssetPlugin create asset entry for you in the first example?