• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript neutrino.Neutrino类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中neutrino.Neutrino的典型用法代码示例。如果您正苦于以下问题:TypeScript Neutrino类的具体用法?TypeScript Neutrino怎么用?TypeScript Neutrino使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Neutrino类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: default

export default (neutrino: Neutrino) => {
  // Add environment variables to bundle.
  neutrino.use(env, getTuxEnv())

  neutrino.use(targetEnv, neutrino.options.target)

  neutrino.use(appEntryConstant, neutrino.options.appEntry)
}
开发者ID:aranja,项目名称:tux,代码行数:8,代码来源:env.ts


示例2: default

export default (neutrino: Neutrino) => {
  // Only write stats files during build. Dev server automatically
  // has access to stats.
  neutrino.on('prebuild', () =>
    neutrino.config.plugin('stats').use(StatsWriterPlugin, [
      {
        fields: ['assetsByChunkName', 'chunks', 'publicPath', 'hash'],
      },
    ])
  )
}
开发者ID:aranja,项目名称:tux,代码行数:11,代码来源:stats.ts


示例3: default

export default (neutrino: Neutrino) => {
  // Configure admin variable.
  if (process.env.ADMIN == null) {
    const { admin } = neutrino.options
    const buildAdmin =
      admin != null ? admin : process.env.NODE_ENV === 'development'
    process.env.ADMIN = buildAdmin ? 'true' : ''
  }

  // Add ADMIN environment variable to bundle.
  neutrino.config.plugin('env').tap(args => args.concat('ADMIN'))

  // Prioritize `source.admin.js` over `source.js` in admin builds.
  if (process.env.ADMIN) {
    neutrino.use(adminExtension)
  }
}
开发者ID:aranja,项目名称:tux,代码行数:17,代码来源:neutrino.ts


示例4: default

export default (neutrino: Neutrino, options: any = {}) => {
  const pkg = getPackageJson(neutrino.options.root)
  const sourceMap = !!(
    (pkg.dependencies && pkg.dependencies['source-map-support']) ||
    (pkg.devDependencies && pkg.devDependencies['source-map-support'])
  )

  neutrino.config.module
    .rule('compile')
    .use('babel')
    .tap(existing =>
      compile.merge(existing, {
        plugins: [
          ...(options.polyfills.async
            ? [[require.resolve('fast-async'), { spec: true }]]
            : []),
          require.resolve('babel-plugin-dynamic-import-node'),
        ],
        presets: [
          [
            'babel-preset-env',
            {
              debug: neutrino.options.debug,
              targets: { node: '6.10' },
              modules: false,
              useBuiltIns: true,
              exclude: options.polyfills.async
                ? ['transform-regenerator', 'transform-async-to-generator']
                : [],
            },
          ],
        ],
      })
    )

  neutrino.use(webCompat)
  // prettier-ignore
  neutrino.config
    .when(sourceMap, () => neutrino.use(banner))
    .performance
      .hints(false)
      .end()
    .target('node')
    .node
      .clear()
      .set('__filename', false)
      .set('__dirname', false)
      .end()
    .devtool('source-map')
    .externals([nodeExternals({ whitelist: [/^webpack/, /tux/] })])
    .entry('index')
      .add(neutrino.options.mains.index)
      .end()
    .output
      .path(neutrino.options.output)
      .filename('[name].js')
      .libraryTarget('commonjs2')
      .chunkFilename('[id].[hash:5]-[chunkhash:7].js')
      .end()
    .when(neutrino.options.env.NODE_ENV === 'development', config => {
      config.devtool('inline-source-map');
    });
}
开发者ID:aranja,项目名称:tux,代码行数:63,代码来源:ssr.ts


示例5: default

export default (neutrino: Neutrino, opts: Partial<Options> = {}) => {
  const isDev = process.env.NODE_ENV === 'development'
  const options = merge<Options>(
    {
      hot: true,
      polyfills: {
        async: true,
      },
      html: {},
    },
    opts as Options
  )

  // This preset depends on a target option, let's give it a default.
  neutrino.options.target = neutrino.options.target || 'browser'
  const isServer = (neutrino.options.isServer =
    neutrino.options.target === 'server')

  // Replace entry based on target.
  neutrino.options.appEntry = neutrino.options.mains.index
  neutrino.options.mains.index = isServer
    ? neutrino.options.serverEntry
    : neutrino.options.browserEntry

  // Build on top of the offical react preset (overriding devServer and open functionality for our own in tux-scripts).
  // Skip react-hot-loader for now while enabling other HMR functionality.
  const reactOptions = merge<any>(options, {
    devServer: { open: false },
    hot: false,
    ...isServer ? { style: { extract: false } } : {},
  })
  neutrino.use(react, reactOptions)

  // Switch to custom html plugin.
  neutrino.use(html, options.html)

  // Add more environment variables.
  neutrino.use(env, options)

  // Write stats files when building.
  neutrino.use(stats)

  // prettier-ignore
  neutrino.config
    // Webpack Hot Server Middleware expects a MultiConfiguration with "server" and "client" names.
    .set('name', isServer ? 'server' : 'client')

    // Remove devServer. We use webpack-dev-middleware for SSR support.
    .devServer.clear().end()

    // Neutrino defaults to relative paths './'. Tux is optimized for SPAs, where absolute paths
    // are a better default.
    .output
      .publicPath('/')
      .end()

    // Fix svg imports: https://github.com/mozilla-neutrino/neutrino-dev/issues/272
    .module
      .rule('svg')
        .use('url')
          .loader(require.resolve('file-loader'))
          .options({ limit: 8192 })
          .end()
        .end()
      .end()

    // Add goodies from create-react-app project.
    .when(isDev, () => {
      neutrino.use(hot)
      neutrino.use(betterDev, options)
    })

  // Wait until all presets and middlewares have run before
  // adapting the config for SSR.
  if (isServer) {
    neutrino.on('prerun', () => neutrino.use(ssr, options))
  }
}
开发者ID:aranja,项目名称:tux,代码行数:78,代码来源:index.ts


示例6:

 .when(sourceMap, () => neutrino.use(banner))
开发者ID:aranja,项目名称:tux,代码行数:1,代码来源:ssr.ts


示例7:

 .when(isDev, () => {
   neutrino.use(hot)
   neutrino.use(betterDev, options)
 })
开发者ID:aranja,项目名称:tux,代码行数:4,代码来源:index.ts



注:本文中的neutrino.Neutrino类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript newrelic.getTransaction函数代码示例发布时间:2022-05-25
下一篇:
TypeScript worker_rpc.RPC类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap