webpack/examples/persistent-caching
Tobias Koppers e5cecdad23 store build dependencies snapshot in pack
add snapshot shortcut for package manager managed paths
add cache.managedPaths
2019-08-13 17:02:37 +02:00
..
README.md store build dependencies snapshot in pack 2019-08-13 17:02:37 +02:00
build.js
example.css store build dependencies snapshot in pack 2019-08-13 17:02:37 +02:00
example.js store build dependencies snapshot in pack 2019-08-13 17:02:37 +02:00
template.md Merge tag 'v4.30.0' into next 2019-05-09 21:34:28 +02:00
webpack.config.js store build dependencies snapshot in pack 2019-08-13 17:02:37 +02:00

README.md

example.js

console.log(process.env.NODE_ENV);

import "./example.css";
import "react";
import "react-dom";
import "acorn";
import "core-js";
import "date-fns";

webpack.config.js

const path = require("path");
module.exports = (env = "development") => ({
	mode: env,
	infrastructureLogging: {
		// Optional: print more verbose logging about caching
		level: "verbose"
	},
	cache: {
		type: "filesystem",

		// changing the cacheDirectory is optional,
		// by default it will be in `node_modules/.cache`
		cacheDirectory: path.resolve(__dirname, ".cache"),

		// Add additional dependencies to the build
		buildDependencies: {
			// recommended to invalidate cache on config changes
			// This also makes all dependencies of this file build dependencies
			config: [__filename]
			// By default webpack and loaders are build dependencies
		}
	},
	module: {
		rules: [
			{
				test: /\.css$/,
				use: ["style-loader", "css-loader"]
			}
		]
	}
});

Info

Hash: 0a1b2c3d4e5f6a7b8c9d
Version: webpack 5.0.0-alpha.19
    Asset     Size  Chunks             Chunk Names
output.js  1.8 MiB     {0}  [emitted]  main
Entrypoint main = output.js
chunk {0} output.js (main) 1.55 MiB (javascript) 1.07 KiB (runtime) [entry]
    > ./example.js main
    530 chunk modules