How to use the neutrino/errors.DuplicateRuleError function in neutrino

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 / 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 neutrinojs / neutrino / packages / style-loader / index.js View on Github external
loaders: [],
      extract: {
        enabled: isProduction,
        loader: {},
        plugin: {
          filename: isProduction
            ? 'assets/[name].[contenthash:8].css'
            : 'assets/[name].css',
        },
      },
    },
    opts,
  );

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

  const extractEnabled = options.extract && options.extract.enabled;
  const rules = [
    merge(options, {
      oneOfId: 'normal',
    }),
  ];

  if (options.modules) {
    rules.unshift(
      merge(options, {
        test: options.modulesTest,
        oneOfId: 'modules',
        css: {
          modules: options.modules,

neutrino

Create and build JS applications with managed configurations

MPL-2.0
Latest version published 4 years ago

Package Health Score

56 / 100
Full package analysis