How to use neutrino - 10 common examples

To help you get started, we’ve selected a few neutrino 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 neutrinojs / neutrino / packages / web / index.js View on Github external
);
  }

  if (
    typeof options.devtool === 'string' ||
    typeof options.devtool === 'boolean'
  ) {
    options.devtool = {
      development: options.devtool,
      production: options.devtool,
      test: options.devtool,
    };
  }

  if (options.style && options.style.extract === true) {
    throw new ConfigurationError(
      'Setting `style.extract` to `true` is no longer supported. Override `style.extract.enabled` instead.',
    );
  }

  // Force @babel/preset-env default behavior (.browserslistrc)
  if (options.targets === false) {
    options.targets = {};
  } else if (!options.targets.node && !options.targets.browsers) {
    options.targets.browsers = [
      'last 2 Chrome versions',
      'last 2 Firefox versions',
      'last 2 Edge versions',
      'last 2 Opera versions',
      'last 2 Safari versions',
      'last 2 iOS versions',
    ];
github neutrinojs / neutrino / packages / eslint / index.js View on Github external
module.exports = ({ test, include, exclude, eslint = {} } = {}) => {
  // Neither eslint-loader nor ESLint's `CLIEngine` fully validate passed options,
  // so we do so here to make it easier to work out why settings seemingly aren't
  // taking effect. This is particularly important given that the configuration
  // options are inconsistently named between CLIEngine and the eslintrc schema.
  // Upstream issues for adding validation:
  // https://github.com/webpack-contrib/eslint-loader/issues/252
  // https://github.com/eslint/eslint/issues/10272
  const invalidOptions = Object.keys(eslint).filter(
    option => !validLoaderOptions.includes(option),
  );

  if (invalidOptions.length) {
    throw new ConfigurationError(
      `Unrecognised 'eslint' option(s): ${invalidOptions.join(', ')}\n` +
        `Valid options are: ${validLoaderOptions.sort().join(', ')}\n` +
        'If trying to set `extends`, `overrides` or `settings`, they must be ' +
        'defined under the `baseConfig` key and not as a top-level option. ' +
        'See: https://neutrinojs.org/packages/eslint/#usage',
    );
  }

  return neutrino => {
    if (neutrino.config.module.rules.has('compile')) {
      throw new ConfigurationError(
        'Lint presets must be defined prior to any other presets in .neutrinorc.js.',
      );
    }

    if (neutrino.config.module.rules.has('lint')) {
github neutrinojs / neutrino / packages / eslint / index.js View on Github external
return neutrino => {
    if (neutrino.config.module.rules.has('compile')) {
      throw new ConfigurationError(
        'Lint presets must be defined prior to any other presets in .neutrinorc.js.',
      );
    }

    if (neutrino.config.module.rules.has('lint')) {
      throw new DuplicateRuleError('@neutrinojs/eslint', 'lint');
    }

    const baseConfig = eslint.baseConfig || {};

    const loaderOptions = {
      // For supported options, see:
      // https://github.com/webpack-contrib/eslint-loader#options
      // https://eslint.org/docs/developer-guide/nodejs-api#cliengine
      cache: true,
      cwd: neutrino.options.root,
github aranja / tux / src / tux-scripts / src / compiler.ts View on Github external
return apiOptions.map(options => {
    const api = Neutrino(options)

    // Register built in commands
    api.register('start', start)
    api.register('build', build)
    api.register('inspect', inspect)
    api.register('test', test)

    // Require and use all configured middlewares.
    args.middleware.forEach(middleware => api.use(middleware))

    return api
  })
}
github neutrinojs / neutrino / packages / eslint / index.js View on Github external
return neutrino => {
    if (neutrino.config.module.rules.has('compile')) {
      throw new ConfigurationError(
        'Lint presets must be defined prior to any other presets in .neutrinorc.js.',
      );
    }

    if (neutrino.config.module.rules.has('lint')) {
      throw new DuplicateRuleError('@neutrinojs/eslint', 'lint');
    }

    const baseConfig = eslint.baseConfig || {};

    const loaderOptions = {
      // For supported options, see:
      // https://github.com/webpack-contrib/eslint-loader#options
      // https://eslint.org/docs/developer-guide/nodejs-api#cliengine
      cache: true,
      cwd: neutrino.options.root,
      // Downgrade errors to warnings when in development, to reduce the noise in
      // the webpack-dev-server overlay (which defaults to showing errors only),
      // and to also ensure hot reloading isn't prevented.
      emitWarning: process.env.NODE_ENV === 'development',
      // Make errors fatal for 'production' and 'test'.
      // However note that even when `false` webpack still fails the build:
github neutrinojs / neutrino / packages / font-loader / index.js View on Github external
module.exports = (options = {}) => neutrino => {
  const ruleId = 'font';
  const isProduction = process.env.NODE_ENV === 'production';
  const defaultOptions = {
    name: isProduction ? 'assets/[name].[hash:8].[ext]' : 'assets/[name].[ext]',
  };

  if (neutrino.config.module.rules.has(ruleId)) {
    throw new DuplicateRuleError('@neutrinojs/font-loader', ruleId);
  }

  neutrino.config.module
    .rule(ruleId)
    .test(/\.(eot|ttf|woff|woff2)(\?v=\d+\.\d+\.\d+)?$/)
    .use('file')
    .loader(require.resolve('file-loader'))
    .options({ ...defaultOptions, ...options });
};
github neutrinojs / neutrino / packages / image-loader / index.js View on Github external
module.exports = (options = {}) => neutrino => {
  const ruleId = 'image';
  const isProduction = process.env.NODE_ENV === 'production';
  const defaultOptions = {
    limit: 8192,
    name: isProduction ? 'assets/[name].[hash:8].[ext]' : 'assets/[name].[ext]',
  };

  if (neutrino.config.module.rules.has(ruleId)) {
    throw new DuplicateRuleError('@neutrinojs/image-loader', ruleId);
  }

  neutrino.config.module
    .rule(ruleId)
    .test(/\.(ico|png|jpg|jpeg|gif|svg|webp)(\?v=\d+\.\d+\.\d+)?$/)
    .use('url')
    .loader(require.resolve('url-loader'))
    .options({ ...defaultOptions, ...options });
};
github neutrinojs / neutrino / packages / compile-loader / index.js View on Github external
} = {}) => neutrino => {
  if (neutrino.config.module.rules.has(ruleId)) {
    throw new DuplicateRuleError('@neutrinojs/compile-loader', ruleId);
  }

  neutrino.config.module
    .rule(ruleId)
    .test(options.test || neutrino.regexFromExtensions())
    .when(options.include, rule => rule.include.merge(options.include))
    .when(options.exclude, rule => rule.exclude.merge(options.exclude))
    .use(useId)
    .loader(require.resolve('babel-loader'))
    .options({
      cacheDirectory: true,
      babelrc: false,
      configFile: false,
      ...(options.babel || {}),
    });
github geops / openlayers-editor / .neutrinorc.js View on Github external
neutrino.on('test', () => new Promise((resolve, reject) =>
    start(neutrino.config.toConfig(), neutrino).fork(
      errors => errors.forEach(err => console.error(err)),
      compiler => cypress.run().then(() => resolve()).catch(() => reject())
    )
  ));
github neutrinojs / neutrino / packages / library / index.js View on Github external
module.exports = (opts = {}) => {
  if (!opts.name) {
    throw new ConfigurationError(
      'Missing required preset option "name". You must specify a library name when using this preset.',
    );
  }

  if ('polyfills' in opts) {
    throw new ConfigurationError(
      'The polyfills option has been removed, since polyfills are no longer included by default.',
    );
  }

  return neutrino => {
    const options = merge(
      {
        target: 'web',
        libraryTarget: 'umd',
        babel: {},

neutrino

Create and build JS applications with managed configurations

MPL-2.0
Latest version published 3 years ago

Package Health Score

59 / 100
Full package analysis