Javascript 网页包清单哈希-未对供应商进行哈希

Javascript 网页包清单哈希-未对供应商进行哈希,javascript,reactjs,webpack,Javascript,Reactjs,Webpack,我一直在学习教程,在这方面,它们的输出总是会被散列,所以就像bundle-18734678.js和vendor-3242232.js-我的bundle是散列的,但出于某种原因,供应商根本没有被散列。下图仅显示了vendor.js 我的网页文件在下面 const path = require('path'); const webpack = require('webpack'); const ExtractTextPlugin = require("extract-text-webpack-pl

我一直在学习教程,在这方面,它们的输出总是会被散列,所以就像
bundle-18734678.js
vendor-3242232.js
-我的bundle是散列的,但出于某种原因,供应商根本没有被散列。下图仅显示了
vendor.js

我的网页文件在下面

const path = require('path');
const webpack = require('webpack');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const CompressionPlugin = require("compression-webpack-plugin");
const ManifestPlugin = require('webpack-manifest-plugin');
const ChunkManifestPlugin = require('chunk-manifest-webpack-plugin');

const vendorPackages = [
  'react', 
  'react-router', 
  'react-redux', 
  'toastr', 
  'lodash'
];

module.exports = {
  entry: {
    bundle: [ './src/index.js' ],
    vendor: vendorPackages
  },

  output: {
    path: path.join(__dirname, '/dist/prod'),
    publicPath: '/dist/prod',
    filename: '[name]-[chunkhash:8].js'
  }, 

  plugins: [ 
      new webpack.DefinePlugin({
        'process.env': {
          NODE_ENV: JSON.stringify('production')
        }
      }),
      new webpack.optimize.CommonsChunkPlugin({
        name: 'vendor',
        filename: 'vendor.js',
        minChunks: Infinity,
      }),

      new ManifestPlugin({
        fileName: 'app-manifest.json',
        basePath: '/'
      }),
      new ChunkManifestPlugin({
        filename: "manifest.json",
        manifestVariable: "webpackManifest"
      }),
      new ExtractTextPlugin("styles.css"),
      new webpack.optimize.DedupePlugin(),
      new CompressionPlugin({
          asset: "[path].gz[query]",
          algorithm: "gzip",
          test: /\.js$|\.html$/,
          threshold: 10240,
          minRatio: 0.8
      })
    ],

  module: {
    rules: [
      // Test: js & jsx
      {
        test: /\.js(x?)$/,
        exclude: /node_modules/,
        loader: 'babel-loader',
        query: {
          presets: ['react', 'es2015', 'stage-1']
        }
      },
      // Test: html
      {
        test: "\.html$",

        use: [
          {
            loader: "html-loader",
            options: {
              /* ... */
            }
          }
        ]
      },
      { test: /\.(png|woff|woff2|eot|ttf|svg)$/, loader: 'url-loader?limit=100000' },
      // Test: css
      {
        test: /\.css$/,
        exclude: /node_modules/,
        loader: 'style-loader!css-loader?localIdentName=[name]__[local]__[hash:base64:5]&modules&importLoaders=1&sourceMap',
      }, 
      // Test: url
      {
        test: /\.(jpe?g|gif|png|svg)$/i,
        loader: 'url-loader?limit=10000',
      }, 
      // Test: json
      {
        test: /\.json$/,
        loader: 'json-loader',
      }
    ]
  }
}
你只要检查一下

你只要检查一下


您可以使用
webpack.optimize.commonchunkplugin
选项将文件命名为“vendor.js”。删除该文件名选项或使用哈希设置值:

new webpack.optimize.CommonsChunkPlugin({
  name: 'vendor',
  filename: 'vendor.js', // <====
  minChunks: Infinity,
}),
新建webpack.optimize.commons插件({
名称:'供应商',

filename:'vendor.js',//您有
webpack.optimize.commonchunkplugin
选项将您的文件命名为'vendor.js'。删除该filename选项或使用哈希设置一个值:

new webpack.optimize.CommonsChunkPlugin({
  name: 'vendor',
  filename: 'vendor.js', // <====
  minChunks: Infinity,
}),
新建webpack.optimize.commons插件({
名称:'供应商',

filename:'vendor.js',//我现在在将哈希文件加载到应用程序中时遇到了一些问题,是否有插件可以为我做到这一点?或者我需要在index.html中使用json输出?太棒了!我会研究一下:)我现在在将散列文件加载到应用程序中时遇到了一些问题,是否有插件可以为我做到这一点?或者我需要在index.html中使用json输出?太棒了!我会研究一下:)