From 75bde5d0953283f7230a69c964e1c257ff9892e2 Mon Sep 17 00:00:00 2001 From: budparr Date: Mon, 9 Apr 2018 11:47:30 -0400 Subject: [PATCH] Hash assets Fixes #60 --- src/webpack.config.js | 51 ++++++++++--------- ... app.4820926d6a88a9adbe776b0b5c678846.css} | 0 ....bundle.js => app.fab48d8a2f2e6b5fd864.js} | 0 3 files changed, 28 insertions(+), 23 deletions(-) rename static/dist/{main.css => app.4820926d6a88a9adbe776b0b5c678846.css} (100%) rename static/dist/{app.bundle.js => app.fab48d8a2f2e6b5fd864.js} (100%) diff --git a/src/webpack.config.js b/src/webpack.config.js index 284cbcb..f0af7ae 100644 --- a/src/webpack.config.js +++ b/src/webpack.config.js @@ -1,6 +1,6 @@ -var path = require("path"); -var ExtractTextPlugin = require("extract-text-webpack-plugin"); -var webpack = require("webpack"); +var path = require('path'); +var ExtractTextPlugin = require('extract-text-webpack-plugin'); +var webpack = require('webpack'); module.exports = { entry: { app: './js/main.js' @@ -8,20 +8,20 @@ module.exports = { module: { rules: [ { - test: /\.js$/, - exclude: /node_modules/, - use: { - loader: 'babel-loader', - options: { - presets: ['env'] - // plugins: [require('babel-plugin-transform-object-rest-spread')] - } - } - }, + test: /\.js$/, + exclude: /node_modules/, + use: { + loader: 'babel-loader', + options: { + presets: ['env'] + // plugins: [require('babel-plugin-transform-object-rest-spread')] + } + } + }, { test: /\.css$/, use: ExtractTextPlugin.extract({ - fallback: "style-loader", + fallback: 'style-loader', use: 'css-loader?importLoaders=1!postcss-loader' }) } @@ -29,22 +29,27 @@ module.exports = { }, output: { - path: path.join(__dirname, "./../static/dist"), - filename: '[name].bundle.js', + path: path.join(__dirname, './../static/dist'), + filename: '[name].[chunkhash].js' }, resolve: { - modules: [path.resolve(__dirname, 'src'), 'node_modules'], + modules: [path.resolve(__dirname, 'src'), 'node_modules'] }, plugins: [ - new ExtractTextPlugin("main.css"), - new webpack.ProvidePlugin({ - $: "jquery", - jQuery: "jquery" - }) + new ExtractTextPlugin({ + filename: getPath => { + return getPath('[name].[contenthash].css'); + }, + allChunks: true + }) + // new webpack.ProvidePlugin({ + // $: "jquery", + // jQuery: "jquery" + // }) ], watchOptions: { watch: true } -} +}; diff --git a/static/dist/main.css b/static/dist/app.4820926d6a88a9adbe776b0b5c678846.css similarity index 100% rename from static/dist/main.css rename to static/dist/app.4820926d6a88a9adbe776b0b5c678846.css diff --git a/static/dist/app.bundle.js b/static/dist/app.fab48d8a2f2e6b5fd864.js similarity index 100% rename from static/dist/app.bundle.js rename to static/dist/app.fab48d8a2f2e6b5fd864.js