mirror of
https://github.com/tenrok/vue-context.git
synced 2026-06-07 16:52:23 +03:00
wip
This commit is contained in:
@@ -15,3 +15,80 @@ filesToDelete.forEach(file => {
|
||||
fs.rmdirSync(__dirname + '/dist', { recursive: true });
|
||||
|
||||
console.log('All extra files cleaned up!');
|
||||
|
||||
// Add "ids" to the files for cache busting, and also update the script references in the docs
|
||||
|
||||
// const docFiles = [
|
||||
// __dirname + '/../docs/demos/basic.md',
|
||||
// __dirname + '/../docs/demos/advanced.md',
|
||||
// ];
|
||||
|
||||
const docFiles = {
|
||||
advanced: __dirname + '/../docs/demos/advanced.md',
|
||||
}
|
||||
|
||||
const scripts = {
|
||||
advanced: __dirname + '/../docs/scripts/vue-context-advanced-demos.js',
|
||||
};
|
||||
|
||||
const renameFile = path => {
|
||||
const id = Date.now();
|
||||
|
||||
const parts = path.split('/');
|
||||
const fileName = parts[parts.length - 1];
|
||||
|
||||
const fileNameParts = fileName.split('.');
|
||||
|
||||
const newName = `${fileNameParts[0]}.${id}.${fileNameParts[1]}`;
|
||||
const newPath = __dirname + '/../docs/scripts/' + newName;
|
||||
|
||||
fs.renameSync(path, newPath);
|
||||
|
||||
return newName;
|
||||
};
|
||||
|
||||
const updateScriptSrc = (markdownFile, newName) => {
|
||||
const content = fs.readFileSync(markdownFile, 'utf-8');
|
||||
const lines = content.split("\n");
|
||||
const scriptLine = lines[lines.length - 2];
|
||||
|
||||
if (scriptLine.startsWith('<script')) {
|
||||
lines[lines.length - 2] = `<script src="../scripts/${newName}"></script>`;
|
||||
}
|
||||
|
||||
fs.writeFileSync(markdownFile, lines.join("\n"));
|
||||
};
|
||||
|
||||
Object.keys(scripts).forEach(key => {
|
||||
const path = scripts[key];
|
||||
const newName = renameFile(path);
|
||||
|
||||
updateScriptSrc(docFiles[key], newName);
|
||||
});
|
||||
|
||||
return;
|
||||
|
||||
fs.readdir(__dirname + '/../docs/scripts', (err, files) => {
|
||||
if (err) {
|
||||
return;
|
||||
}
|
||||
|
||||
files.forEach(file => {
|
||||
const id = Date.now();
|
||||
|
||||
const oldPath = __dirname + '/../docs/scripts/' + file;
|
||||
|
||||
const parts = file.split('.');
|
||||
|
||||
const newPath = __dirname + '/../docs/scripts/' + parts[0] + `.${id}.` + parts[1];
|
||||
|
||||
fs.renameSync(oldPath, newPath);
|
||||
|
||||
docFiles.forEach(doc => {
|
||||
const content = fs.readFileSync(doc, 'utf-8');
|
||||
const regex = new RegExp("<script[\s\S]*?>[\s\S]*?<\/script>", 'gi');
|
||||
|
||||
console.log(content.replace(regex, '<foo>'));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -20,4 +20,4 @@ new Vue({
|
||||
components: {
|
||||
NestedMenus,
|
||||
},
|
||||
}).$mount('#nested-menus');
|
||||
}).$mount('#nested-app');
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
const mix = require('laravel-mix');
|
||||
const fs = require('fs');
|
||||
|
||||
// Cleanup the old scripts, since we'll be re-hashing them.
|
||||
fs.rmdirSync(__dirname + '/../docs/scripts', { recursive: true });
|
||||
|
||||
mix
|
||||
.js('js/index.js', 'dist/vue-context-demos.js')
|
||||
|
||||
@@ -304,4 +304,4 @@ export default {
|
||||
|
||||
[Demo Source](https://github.com/rawilk/vue-context/blob/master/docs-build/js/advanced/nested-menus.vue)
|
||||
|
||||
<script src="../scripts/vue-context-advanced-demos.js"></script>
|
||||
<script src="../scripts/vue-context-advanced-demos.1598840380789.js"></script>
|
||||
|
||||
+1
-1
@@ -275,7 +275,7 @@ new vue__WEBPACK_IMPORTED_MODULE_0___default.a({
|
||||
components: {
|
||||
NestedMenus: _nested_menus__WEBPACK_IMPORTED_MODULE_3__["default"]
|
||||
}
|
||||
}).$mount('#nested-menus');
|
||||
}).$mount('#nested-app');
|
||||
|
||||
/***/ }),
|
||||
|
||||
Reference in New Issue
Block a user