Best JavaScript code snippet using storybook-root
gather-static.js
Source:gather-static.js
1// Gulp task to gather all static files.2const gulp = require("gulp");3const path = require("path");4const fs = require("fs-extra");5const paths = require("../paths");6const npmPath = (...parts) =>7 path.resolve(paths.polymer_dir, "node_modules", ...parts);8const polyPath = (...parts) => path.resolve(paths.polymer_dir, ...parts);9const copyFileDir = (fromFile, toDir) =>10 fs.copySync(fromFile, path.join(toDir, path.basename(fromFile)));11const genStaticPath =12 (staticDir) =>13 (...parts) =>14 path.resolve(staticDir, ...parts);15function copyTranslations(staticDir) {16 const staticPath = genStaticPath(staticDir);17 // Translation output18 fs.copySync(19 polyPath("build/translations/output"),20 staticPath("translations")21 );22}23function copyLocaleData(staticDir) {24 const staticPath = genStaticPath(staticDir);25 // Locale data output26 fs.copySync(polyPath("build/locale-data"), staticPath("locale-data"));27}28function copyMdiIcons(staticDir) {29 const staticPath = genStaticPath(staticDir);30 // MDI icons output31 fs.copySync(polyPath("build/mdi"), staticPath("mdi"));32}33function copyPolyfills(staticDir) {34 const staticPath = genStaticPath(staticDir);35 // For custom panels using ES5 builds that don't use Babel 7+36 copyFileDir(37 npmPath("@webcomponents/webcomponentsjs/custom-elements-es5-adapter.js"),38 staticPath("polyfills/")39 );40 // Web Component polyfills and adapters41 copyFileDir(42 npmPath("@webcomponents/webcomponentsjs/webcomponents-bundle.js"),43 staticPath("polyfills/")44 );45 copyFileDir(46 npmPath("@webcomponents/webcomponentsjs/webcomponents-bundle.js.map"),47 staticPath("polyfills/")48 );49}50function copyLoaderJS(staticDir) {51 const staticPath = genStaticPath(staticDir);52 copyFileDir(npmPath("systemjs/dist/s.min.js"), staticPath("js"));53 copyFileDir(npmPath("systemjs/dist/s.min.js.map"), staticPath("js"));54}55function copyFonts(staticDir) {56 const staticPath = genStaticPath(staticDir);57 // Local fonts58 fs.copySync(59 npmPath("roboto-fontface/fonts/roboto/"),60 staticPath("fonts/roboto/"),61 {62 filter: (src) => !src.includes(".") || src.endsWith(".woff2"),63 }64 );65}66function copyQrScannerWorker(staticDir) {67 const staticPath = genStaticPath(staticDir);68 copyFileDir(npmPath("qr-scanner/qr-scanner-worker.min.js"), staticPath("js"));69}70function copyMapPanel(staticDir) {71 const staticPath = genStaticPath(staticDir);72 copyFileDir(73 npmPath("leaflet/dist/leaflet.css"),74 staticPath("images/leaflet/")75 );76 fs.copySync(77 npmPath("leaflet/dist/images"),78 staticPath("images/leaflet/images/")79 );80}81gulp.task("copy-locale-data", async () => {82 const staticDir = paths.app_output_static;83 copyLocaleData(staticDir);84});85gulp.task("copy-translations-app", async () => {86 const staticDir = paths.app_output_static;87 copyTranslations(staticDir);88});89gulp.task("copy-translations-supervisor", async () => {90 const staticDir = paths.hassio_output_static;91 copyTranslations(staticDir);92});93gulp.task("copy-locale-data-supervisor", async () => {94 const staticDir = paths.hassio_output_static;95 copyLocaleData(staticDir);96});97gulp.task("copy-static-app", async () => {98 const staticDir = paths.app_output_static;99 // Basic static files100 fs.copySync(polyPath("public"), paths.app_output_root);101 copyLoaderJS(staticDir);102 copyPolyfills(staticDir);103 copyFonts(staticDir);104 copyTranslations(staticDir);105 copyLocaleData(staticDir);106 copyMdiIcons(staticDir);107 // Panel assets108 copyMapPanel(staticDir);109 // Qr Scanner assets110 copyQrScannerWorker(staticDir);111});112gulp.task("copy-static-demo", async () => {113 // Copy app static files114 fs.copySync(115 polyPath("public/static"),116 path.resolve(paths.demo_output_root, "static")117 );118 // Copy demo static files119 fs.copySync(path.resolve(paths.demo_dir, "public"), paths.demo_output_root);120 copyLoaderJS(paths.demo_output_static);121 copyPolyfills(paths.demo_output_static);122 copyMapPanel(paths.demo_output_static);123 copyFonts(paths.demo_output_static);124 copyTranslations(paths.demo_output_static);125 copyLocaleData(paths.demo_output_static);126 copyMdiIcons(paths.demo_output_static);127});128gulp.task("copy-static-cast", async () => {129 // Copy app static files130 fs.copySync(polyPath("public/static"), paths.cast_output_static);131 // Copy cast static files132 fs.copySync(path.resolve(paths.cast_dir, "public"), paths.cast_output_root);133 copyLoaderJS(paths.cast_output_static);134 copyPolyfills(paths.cast_output_static);135 copyMapPanel(paths.cast_output_static);136 copyFonts(paths.cast_output_static);137 copyTranslations(paths.cast_output_static);138 copyLocaleData(paths.cast_output_static);139 copyMdiIcons(paths.cast_output_static);140});141gulp.task("copy-static-gallery", async () => {142 // Copy app static files143 fs.copySync(polyPath("public/static"), paths.gallery_output_static);144 // Copy gallery static files145 fs.copySync(146 path.resolve(paths.gallery_dir, "public"),147 paths.gallery_output_root148 );149 copyMapPanel(paths.gallery_output_static);150 copyFonts(paths.gallery_output_static);151 copyTranslations(paths.gallery_output_static);152 copyLocaleData(paths.gallery_output_static);153 copyMdiIcons(paths.gallery_output_static);...
gulpfile.js
Source:gulpfile.js
1'use strict';2// require3var gulp = require('gulp');4var del = require('del');5var sass = require('gulp-sass');6var ts = require('gulp-typescript');7var tsProject = ts.createProject('tsconfig.json', {typescript: require('typescript')});8// vars9var staticDir = '../../../../build/generated-web-resources/static/app/';10// lib copy11gulp.task('libcopy', function() {12 // clean dest using sync13 del.sync([staticDir + 'js/lib/**',14 staticDir + 'css/lib/**'], {force: true});15 // copy libs16 gulp.src(['./node_modules/@angular/**/*'])17 .pipe(gulp.dest(staticDir + 'js/lib/@angular'));18 gulp.src(['./node_modules/angular2-in-memory-web-api/**/*'])19 .pipe(gulp.dest(staticDir + 'js/lib/angular2-in-memory-web-api'));20 gulp.src(['./node_modules/symbol-observable/**/*'])21 .pipe(gulp.dest(staticDir + 'js/lib/symbol-observable'));22 gulp.src(['./node_modules/rxjs/**/*'])23 .pipe(gulp.dest(staticDir + 'js/lib/rxjs'));24 // copy @angular dependencies25 gulp.src(['./node_modules/zone.js/dist/zone.js',26 './node_modules/reflect-metadata/Reflect.js',27 './node_modules/systemjs/dist/system.src.js'])28 .pipe(gulp.dest(staticDir + 'js/lib'));29 // copy jasmine-core dependencies30 gulp.src(['./node_modules/jasmine-core/lib/jasmine-core/jasmine.js',31 './node_modules/jasmine-core/lib/jasmine-core/jasmine-html.js',32 './node_modules/jasmine-core/lib/jasmine-core/boot.js'])33 .pipe(gulp.dest(staticDir + 'js/lib'));34 gulp.src(['./node_modules/jasmine-core/lib/jasmine-core/jasmine.css'])35 .pipe(gulp.dest(staticDir + 'css/lib'));36 gulp.src(['./node_modules/angular2-materialize/**/*'])37 .pipe(gulp.dest(staticDir + "js/lib/angular2-materialize"));38 gulp.src(['./node_modules/materialize-css/dist/css/materialize.min.css'])39 .pipe(gulp.dest(staticDir + "css/lib"));40 // copy bootstrap dependencies41 gulp.src(['./node_modules/jquery/dist/jquery.min.js',42 './node_modules/tether/dist/js/tether.min.js',43 './node_modules/bootstrap/dist/js/bootstrap.min.js',44 './node_modules/moment/min/moment.min.js',45 './node_modules/ng2-bootstrap/bundles/ng2-bootstrap.min.js'])46 .pipe(gulp.dest(staticDir + 'js/lib'));47 gulp.src(['./node_modules/tether/dist/css/tether.min.css',48 './node_modules/bootstrap/dist/css/bootstrap.min.css'])49 .pipe(gulp.dest(staticDir + 'css/lib'));50 // copy font-awesome51 gulp.src(['./node_modules/font-awesome/css/font-awesome.min.css'])52 .pipe(gulp.dest(staticDir + 'css/lib/font-awesome/css'));53 gulp.src(['./node_modules/font-awesome/fonts/*'])54 .pipe(gulp.dest(staticDir + 'css/lib/font-awesome/fonts'));55 //copy custom libraries56 gulp.src(["./app/**/*.css"])57 .pipe(gulp.dest(staticDir))58});59// html/config copy60gulp.task('htmlcopy', function() {61 // clean dest62 del([staticDir + 'index.html',63 staticDir + 'systemjs.config.js',64 staticDir + 'jasmine/**/*.html',65 staticDir + 'app/**/*.html'], {force:true});66 // copy index && systemjs cofnig67 gulp.src(['./index.html', './systemjs.config.js'])68 .pipe(gulp.dest(staticDir));69 // copy unit-test html70 gulp.src('./jasmine/**/*.html')71 .pipe(gulp.dest(staticDir + 'jasmine'));72 // copy angular templates73 gulp.src('./app/**/*.html')74 .pipe(gulp.dest(staticDir));75});76// html watch77gulp.task('htmlw', function() {78 // watch index && systemjs config79 gulp.watch(['./index.html', './systemjs.config.js'], ['htmlcopy']);80 // watch angular templates81 gulp.watch('./app/**/*.html', ['htmlcopy']);82 // watch tests for changes83 gulp.watch('./jasmine/**/*.html', ['htmlcopy']);84});85// sass compile86gulp.task('sass', function() {87 // clean dest88 del([staticDir + 'css/*', '!' + staticDir + 'css/lib'], {force: true});89 // compile sass and copy90 return gulp.src('./sass/**/*.scss')91 .pipe(sass.sync().on('error', sass.logError))92 .pipe(gulp.dest(staticDir + 'css'));93});94// sass watch compile95gulp.task('sassw', function() {96 gulp.watch('./sass/**/*.scss', ['sass']);97});98// typescript compile99gulp.task('tsc', function() {100 // clean src dest101 del([staticDir + 'app/**/*.js'], {force: true});102 // clean test dest103 del([staticDir + 'jasmine/**/*.js'], {force: true});104 // compile typescript105 var tsResult = tsProject.src().pipe(ts(tsProject));106 // copy107 return tsResult.js.pipe(gulp.dest(staticDir));108});109// typescript watch compile110gulp.task('tscw', function() {111 gulp.watch(['./app/**/*.ts',112 './app/**/*.html',113 './jasmine/**/*.ts'],114 ['htmlcopy', 'tsc']);115});116// build sass and ts, copy libs, copy html117gulp.task('build', ['htmlcopy', 'sass', 'tsc', 'libcopy']);118// watch sass, ts, and html119gulp.task('watch', ['build', 'sassw', 'htmlw', 'tscw']);120// default...
Using AI Code Generation
1import { staticDir } from 'storybook-root-decorator';2import { addDecorator } from '@storybook/react';3addDecorator(staticDir(__dirname, 'public'));4import { withStaticDir } from 'storybook-addon-static-dir';5import { addDecorator } from '@storybook/react';6addDecorator(withStaticDir(__dirname, 'public'));7import { withStaticDir } from 'storybook-addon-react-static-dir';8import { addDecorator } from '@storybook/react';9addDecorator(withStaticDir(__dirname, 'public'));10import { withStaticDir } from 'storybook-addon-static-files';11import { addDecorator } from '@storybook/react';12addDecorator(withStaticDir(__dirname, 'public'));13import { withStaticDir } from 'storybook-static-files-loader';14import { addDecorator } from '@storybook/react';15addDecorator(withStaticDir(__dirname, 'public'));16import { withStaticDir } from 'storybook-static-files';17import { addDecorator } from '@storybook/react';18addDecorator(withStaticDir(__dirname, 'public'));19import { withStaticDir } from 'storybook-static';20import { addDecorator } from '@storybook/react';21addDecorator(withStaticDir(__dirname, 'public'));22import { withStaticDir } from 'storybook-static-files';23import { addDecorator } from '@storybook/react';24addDecorator(withStaticDir(__dirname, 'public'));25import { withStaticDir } from 'storybook-static-files';26import { addDecorator } from '@storybook/react';27addDecorator(withStaticDir(__dirname, 'public'));28import { withStaticDir } from 'storybook-static-files';29import { addDecorator } from '@storybook/react';30addDecorator(withStaticDir(__dirname, 'public'));31import { withStaticDir } from 'storybook-static-files';32import { addDecorator } from '@storybook/react';33addDecorator(withStaticDir(__
Using AI Code Generation
1var storybookRootDir = require('storybook-root-dir').default;2var staticDir = storybookRootDir('static');3console.log(staticDir);4import storybookRootDir from 'storybook-root-dir';5const staticDir = storybookRootDir('static');6console.log(staticDir);7var storybookRootDir = require('storybook-root-dir').default;8var staticDir = storybookRootDir('static');9console.log(staticDir);10import storybookRootDir from 'storybook-root-dir';11const staticDir = storybookRootDir('static');12console.log(staticDir);13var storybookRootDir = require('storybook-root-dir').default;14var staticDir = storybookRootDir('static');15console.log(staticDir);16import storybookRootDir from 'storybook-root-dir';17const staticDir = storybookRootDir('static');18console.log(staticDir);19var storybookRootDir = require('storybook-root-dir').default;20var staticDir = storybookRootDir('static');21console.log(staticDir);22import storybookRootDir from 'storybook-root-dir';23const staticDir = storybookRootDir('static');24console.log(staticDir);25const path = require('path');26const storybookRootDir = require('storybook-root-dir').default;27module.exports = (baseConfig, env, config) => {28 config.module.rules.push({29 include: path.resolve(storybookRootDir(), '../'),30 });31 return config;32};33import '@storybook/addon-actions/register';34import '@storybook/addon-links/register';35import '@storybook/addon-knobs/register';36import { configure } from '@storybook/react';
Using AI Code Generation
1import { configure } from "@storybook/react";2import staticDir from "storybook-root-decorator";3configure(() => {4 staticDir("public");5 require("./stories");6}, module);7{8 {9 },10 {11 }12}
Using AI Code Generation
1import { staticDir } from 'storybook-root-alias';2console.log(staticDir);3import { staticDir } from 'storybook-root-alias';4console.log(staticDir);5const { staticDir } = require('storybook-root-alias');6console.log(staticDir);7const { staticDir } = require('storybook-root-alias');8console.log(staticDir);9const { staticDir } = require('storybook-root-alias');10console.log(staticDir);11const { staticDir } = require('storybook-root-alias');12console.log(staticDir);13const { staticDir } = require('storybook-root-alias');14console.log(staticDir);15const { staticDir } = require('storybook-root-alias');16console.log(staticDir);17const { staticDir } = require('storybook-root-alias');18console.log(staticDir);
Using AI Code Generation
1var root = require('storybook-root-require').staticDir;2var path = require('path');3var myFile = path.join(root, 'src', 'myFile.js');4var root = require('storybook-root-require').staticDir;5var path = require('path');6var myFile = path.join(root, 'src', 'myFile.js');7var root = require('storybook-root-require').staticDir;8var path = require('path');9var myFile = path.join(root, 'src', 'myFile.js');10var root = require('storybook-root-require').staticDir;11var path = require('path');12var myFile = path.join(root, 'src', 'myFile.js');13var root = require('storybook-root-require').staticDir;14var path = require('path');15var myFile = path.join(root, 'src', 'myFile.js');16var root = require('storybook-root-require').staticDir;17var path = require('path');18var myFile = path.join(root, 'src', 'myFile.js');19var root = require('storybook-root-require').staticDir;20var path = require('path');21var myFile = path.join(root, 'src', 'myFile.js');22var root = require('storybook-root-require').staticDir;
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!