@vnejs/build 0.0.34 → 0.0.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -36,6 +36,10 @@ const getScriptLoader = () => ({
|
|
|
36
36
|
|
|
37
37
|
const getCssLoader = () => [{ loader: `style-loader` }, { loader: `css-loader` }];
|
|
38
38
|
|
|
39
|
+
const webpackChunkPattern = /^(index|vendors|uis|bundle)\.[a-f0-9]+\.js$/;
|
|
40
|
+
|
|
41
|
+
const isWebpackOutput = (asset) => asset === "index.html" || webpackChunkPattern.test(asset) || asset.startsWith("assets/");
|
|
42
|
+
|
|
39
43
|
const getVnejsScopedPackageNames = (rootPath, scopePrefix) => {
|
|
40
44
|
let dir = rootPath;
|
|
41
45
|
|
|
@@ -109,7 +113,11 @@ module.exports = (rootPath, options) => {
|
|
|
109
113
|
extensions: [".js", ".jsx", ".ts", ".tsx", ".css"],
|
|
110
114
|
alias: { "react": resolvePackageDir("react"), "react-dom": resolvePackageDir("react-dom") },
|
|
111
115
|
},
|
|
112
|
-
output: {
|
|
116
|
+
output: {
|
|
117
|
+
path: distPath,
|
|
118
|
+
filename: "[name].[contenthash].js",
|
|
119
|
+
clean: { keep: (asset) => !isWebpackOutput(asset) },
|
|
120
|
+
},
|
|
113
121
|
plugins: [
|
|
114
122
|
new webpack.DefinePlugin({ "process.env.NODE_ENV": `"${isDev ? "development" : "production"}"` }),
|
|
115
123
|
new HtmlWebpackPlugin({ filename: "index.html", template: path.join(rootPath, entryDir, "index.html"), chunks: htmlChunks, chunksSortMode: "manual" }),
|
package/src/data/index.js
CHANGED
|
@@ -22,17 +22,19 @@ const buildDataFunc = (gameDir, distDir) => {
|
|
|
22
22
|
fs.writeFileSync(path.join(distDir, "mods.json"), JSON.stringify(fs.readdirSync(gameDir)));
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
-
const
|
|
26
|
-
fs.
|
|
27
|
-
|
|
25
|
+
const cleanJsonFiles = (distDir) => {
|
|
26
|
+
fs.mkdirSync(distDir, { recursive: true });
|
|
27
|
+
|
|
28
|
+
fs.readdirSync(distDir).forEach((file) => {
|
|
29
|
+
file.endsWith(".json") && fs.rmSync(path.join(distDir, file), { force: true });
|
|
30
|
+
});
|
|
28
31
|
};
|
|
29
32
|
|
|
30
33
|
module.exports = (rootDir) => (options) => {
|
|
31
34
|
const gameDir = path.join(rootDir, "game");
|
|
32
35
|
const distDir = path.join(rootDir, "dist");
|
|
33
36
|
|
|
34
|
-
|
|
35
|
-
|
|
37
|
+
cleanJsonFiles(distDir);
|
|
36
38
|
buildDataFunc(gameDir, distDir);
|
|
37
39
|
|
|
38
40
|
options.watch && fs.watch(gameDir, { recursive: true }, (eventType, filename) => filename && buildDataFunc(gameDir, distDir));
|