Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot determine asset for chunk 1 #83

Closed
abraham opened this issue Sep 11, 2018 · 2 comments
Closed

Cannot determine asset for chunk 1 #83

abraham opened this issue Sep 11, 2018 · 2 comments
Labels

Comments

@abraham
Copy link

abraham commented Sep 11, 2018

WARNING in webpack-subresource-integrity: Cannot determine asset for chunk 1, computed="style-bcdc400faeee6f1e1853.js", available=style-9a9a610f150286f63b30.css. Please report this full error message along with your Webpack configuration at https://github.com/waysact/webpack-subresource-integrity/issues/new

const chunkHash = require('webpack-chunk-hash');
const copy = require('copy-webpack-plugin');
const exclude = require('html-webpack-exclude-assets-plugin');
const extension = require('script-ext-html-webpack-plugin');
const extract = require('mini-css-extract-plugin');
const html = require('html-webpack-plugin');
const inline = require('html-webpack-inline-source-plugin');
const path = require('path');
const workbox = require('workbox-webpack-plugin');
const sri = require('webpack-subresource-integrity');

const production = process.env.NODE_ENV === 'production';

module.exports = {
  context: path.resolve(__dirname, 'src'),
  mode: production ? 'production' : 'development',
  entry: './index.ts',
  devServer: {
    contentBase: path.resolve(__dirname, 'src'),
    hot: false
  },
  output: {
    crossOriginLoading: 'anonymous',
    chunkFilename: '[name]-[chunkhash].js',
    filename: '[name]-[contenthash].js',
    path: path.resolve(__dirname, 'public'),
  },
  optimization: {
    splitChunks: {
      cacheGroups: {
        styles: {
          name: 'style',
          test: /\.css$/,
          chunks: 'all',
          enforce: true
        }
      }
    }
  },
  plugins: [
    new extract({ filename: '[name]-[contenthash].css' }),
    new html({
      excludeAssets: [/style-.*\.js/],
      filename: 'index.html',
      inlineSource: '.(css)$',
      template: path.resolve(__dirname, 'src', 'index.html'),
    }),
    new inline(),
    new chunkHash(),
    new extension({ defaultAttribute: 'async' }),
    new workbox.InjectManifest({
      swSrc: path.resolve(__dirname, 'src', 'sw.js'),
      swDest: 'sw.js',
    }),
    new copy([
      {
        from: '*.txt',
        to: '.',
      },
      {
        from: '*.ico',
        to: '.',
      },
      {
        from: '*.png',
        to: '.',
      },
      {
        from: 'img/*',
        to: '.',
      },
      {
        from: '*.json',
        to: '.',
      },
    ]),
    new sri({
      hashFuncNames: ['sha256', 'sha384'],
      enabled: production,
    }),
  ],
  module: {
    rules: [
      { test: /\.tsx?$/, loader: "ts-loader" },
      {
        test: /\.css$/,
        use: [
          extract.loader,
          'css-loader',
          {
            loader: 'sass-loader',
            options: {
              includePaths: [path.resolve(__dirname, 'node_modules')]
            },
          },
        ],
      },
    ],
  },
};

This is with a slight modification of my personal site. filename: '[name]-[chunkhash].js' to filename: '[name]-[contenthash].js'

jscheid added a commit that referenced this issue Sep 11, 2018
@jscheid jscheid added the bug label Sep 11, 2018
@jscheid
Copy link
Collaborator

jscheid commented Sep 11, 2018

Thanks for reporting this, fix is underway. I'll get to a release tomorrow probably.

@abraham
Copy link
Author

abraham commented Sep 15, 2018

Fix looks good 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants