How to use the umi-utils.prettierFile function in umi-utils

To help you get started, we’ve selected a few umi-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github umijs / umi / packages / umi-build-dev / src / FilesGenerator.js View on Github external
generateRouterJS() {
    const { paths } = this.service;
    const { absRouterJSPath } = paths;
    this.RoutesManager.fetchRoutes();

    const routesContent = this.getRouterJSContent();
    // 避免文件写入导致不必要的 webpack 编译
    if (this.routesContent !== routesContent) {
      writeFileSync(absRouterJSPath, prettierFile(`${routesContent.trim()}\n`), 'utf-8');
      this.routesContent = routesContent;
      this.service.applyPlugins('onRouteChange');
    }
  }
github umijs / umi / packages / umi-build-dev / src / FilesGenerator.js View on Github external
let history = this.service.applyPlugins('modifyEntryHistory', {
      initialValue: initialHistory,
    });
    if (config.ssr) {
      history = `
__IS_BROWSER ? ${initialHistory} : require('history').createMemoryHistory({
  // for history object in dva
  initialEntries: [global.req ? global.req.url : '/']
})
      `.trim();
    }
    const content = Mustache.render(tpl, {
      globalVariables: !this.service.config.disableGlobalVariables,
      history,
    });
    writeContent(join(paths.absTmpDirPath, 'history.js'), prettierFile(`${content.trim()}\n`));
  }
github umijs / umi / packages / umi-build-dev / src / FilesGenerator.js View on Github external
initialValue: [],
        }),
      ).join('\n'),
      polyfillImports: importsToStr(
        this.service.applyPlugins('addEntryPolyfillImports', {
          initialValue: [],
        }),
      ).join('\n'),
      moduleBeforeRenderer,
      render: initialRender,
      plugins,
      validKeys,
      htmlTemplateMap: htmlTemplateMap.join('\n'),
      findRoutePath: winPath(require.resolve('./findRoute')),
    });
    writeContent(paths.absLibraryJSPath, prettierFile(`${entryContent.trim()}\n`));
  }