How to use the @sanity/server.applyStaticLoaderFix function in @sanity/server

To help you get started, we’ve selected a few @sanity/server 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 sanity-io / sanity / packages / storybook / webpack.config.js View on Github external
module.exports = (storyWpConfig, configType) => {
  /* eslint-disable strict */

  'use strict'

  const sanityWpConfig = sanityServer.getWebpackBaseConfig({
    basePath: __dirname,
    commonChunkPlugin: false
  })

  sanityWpConfig.module = sanityWpConfig.module || {loaders: []}

  if (configType.toLowerCase() === 'development') {
    sanityWpConfig.module.loaders = sanityServer.applyStaticLoaderFix(sanityWpConfig, {
      httpHost: 'localhost',
      httpPort: 9001,
      staticPath: './static'
    })
  }

  return Object.assign({}, sanityWpConfig, storyWpConfig, {
    plugins: [].concat(storyWpConfig.plugins, sanityWpConfig.plugins || []),
    resolve: Object.assign({}, storyWpConfig.resolve, sanityWpConfig.resolve, {
      alias: Object.assign({}, storyWpConfig.resolve.alias || {}, sanityWpConfig.resolve.alias || {})
    }),
    module: Object.assign({}, storyWpConfig.module, sanityWpConfig.module, {
      loaders: [].concat(storyWpConfig.module.loaders, sanityWpConfig.module.loaders)
    })
  })
}
github sanity-io / sanity / packages / @sanity / storybook / server / storyConfig / webpack.config.js View on Github external
const sanityWpConfig = sanityServer.getWebpackBaseConfig({
    basePath: process.cwd(),
    commonChunkPlugin: false
  })

  let storybookConf = {}
  try {
    storybookConf = require(path.join(process.cwd(), 'sanity.json')).storybook
  } catch (err) {
    throw err
  }

  sanityWpConfig.module = sanityWpConfig.module || {loaders: []}

  if (configType === 'DEVELOPMENT') {
    sanityWpConfig.module.loaders = sanityServer.applyStaticLoaderFix(sanityWpConfig, {
      listen: Object.assign({
        hostname: 'localhost',
        port: 9001,
        staticPath: './static'
      }, storybookConf)
    })
  }

  return Object.assign({}, sanityWpConfig, storyWpConfig, {
    plugins: [].concat(storyWpConfig.plugins, sanityWpConfig.plugins || []),
    module: Object.assign({}, storyWpConfig.module, sanityWpConfig.module, {
      loaders: [].concat(storyWpConfig.module.loaders, sanityWpConfig.module.loaders)
    })
  })
}