This repository was archived by the owner on Jan 3, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfig-overrides.js
61 lines (60 loc) · 2.02 KB
/
config-overrides.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
const path = require("path");
const fs = require("fs");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
module.exports = {
webpack: function(config, env) {
if (process.argv[process.argv.length - 1] !== "mix") {
return config;
}
config.output.filename = "js/[name].js";
config.output.chunkFilename = "js/[name].js";
// config.plugins.MiniCssExtractPlugin.options.filename = "css/[name].css";
// config.plugins.MiniCssExtractPlugin.options.chunkFilename =
// "css/[name].chunk.css";
for (let i = 0; i < config.plugins.length; i++) {
if (config.plugins[i].constructor.name === "MiniCssExtractPlugin") {
config.plugins[i] = new MiniCssExtractPlugin({
filename: "css/[name].css",
chunkFilename: "css/[name].css"
});
}
}
for (let i = 0; i < config.module.rules[2].oneOf.length; i++) {
if (
config.module.rules[2].oneOf[i].options &&
config.module.rules[2].oneOf[i].options.name
) {
config.module.rules[2].oneOf[
i
].options.name = config.module.rules[2].oneOf[i].options.name.replace(
/(static\/|\.\[hash:8])/g,
""
);
}
}
config.optimization.splitChunks = {
chunks: "all",
name: true,
automaticNameDelimiter: "-"
};
config.plugins.push({
apply: compiler => {
compiler.hooks.afterEmit.tap("AfterEmitPlugin", compilation => {
fs.unlinkSync(path.resolve(__dirname, "public/index.html"));
});
}
});
return config;
},
paths: function(paths, env) {
paths.appIndexJs = path.resolve(__dirname, "resources/js/index.js");
paths.appSrc = path.resolve(__dirname, "resources/js");
paths.appPublic = path.resolve(__dirname, "resources/public");
paths.appHtml = path.resolve(__dirname, "resources/public/index.html");
if (process.argv[process.argv.length - 1] !== "mix") {
return paths;
}
paths.appBuild = path.resolve(__dirname, "public");
return paths;
}
};