Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const path = require('path');
- const fs = require('fs');
- const vendor_dir = path.resolve(__dirname, 'public/static/vendor')
- function copyFromNodeModules(src, dest) {
- /*
- * src - relative from node_modules directory
- * dest - should be absolute path
- */
- for (let dir in module.paths) {
- let file = path.resolve(module.paths[dir], src);
- if (fs.existsSync(file)) {
- fs.mkdirSync(path.dirname(dest), {recursive: true});
- fs.copyFile(file, dest, (err) => {
- if (err) {
- throw err;
- }
- console.log(`Copy file: "${file}" to: "${dest}"`);
- });
- return true
- }
- }
- throw new Error(`File: "${src}" not found in paths: ${module.paths}`)
- }
- // Cleanup
- fs.rmSync(vendor_dir, {recursive: true, force: true});
- fs.mkdirSync(vendor_dir, {recursive: true});
- // Copy files
- copyFromNodeModules('bootstrap/dist/js/bootstrap.bundle.min.js', path.resolve(vendor_dir, 'bootstrap/bootstrap.bundle.min.js'));
- copyFromNodeModules('bootstrap/dist/css/bootstrap.min.css', path.resolve(vendor_dir, 'bootstrap/bootstrap.min.css'));
- copyFromNodeModules('bootstrap/dist/css/bootstrap.min.css.map', path.resolve(vendor_dir, 'bootstrap/bootstrap.min.css.map'));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement