Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vue inspect --rules error #2206

Closed
JFGHT opened this issue Aug 14, 2018 · 4 comments
Closed

vue inspect --rules error #2206

JFGHT opened this issue Aug 14, 2018 · 4 comments
Labels

Comments

@JFGHT
Copy link

JFGHT commented Aug 14, 2018

Version

3.0.0

Node and OS info

yarn 1.9.4 / Linux Mint 19

Steps to reproduce

Just typing vue inspect --rule vue OR vue inspect --rules shows this error.

What is expected?

A list of webpack rules.

What is actually happening?

TypeError: Cannot read property '0' of undefined
at config.module.rules.map.r (/home/jesus/apps/annexum-new-webpack/node_modules/@vue/cli-service/lib/commands/inspect.js:25:55)
at Array.map ()
at api.registerCommand.args (/home/jesus/apps/annexum-new-webpack/node_modules/@vue/cli-service/lib/commands/inspect.js:25:33)
at Service.run (/home/jesus/apps/annexum-new-webpack/node_modules/@vue/cli-service/lib/Service.js:203:12)
at Object. (/home/jesus/apps/annexum-new-webpack/node_modules/@vue/cli-service/bin/vue-cli-service.js:22:9)
at Module._compile (module.js:649:30)
at Object.Module._extensions..js (module.js:660:10)
at Module.load (module.js:561:32)
at tryModuleLoad (module.js:501:12)
at Function.Module._load (module.js:493:3)
at Function.Module.runMain (module.js:690:10)
at startup (bootstrap_node.js:194:16)
at bootstrap_node.js:666:3

@haoqunjiang
Copy link
Member

Could you provide your vue.config.js please? I suppose it is caused by some custom rules in your config file.

@haoqunjiang haoqunjiang added the needs reproduction This issue is missing a minimal runnable reproduction, provided by the author label Aug 14, 2018
@JFGHT
Copy link
Author

JFGHT commented Aug 14, 2018

Here you are:

const StyleLintPlugin = require('stylelint-webpack-plugin');

module.exports = {
  devServer: {
    https: true,
  },
  // Fixing CircleCi Bug related to thread-loader
  parallel: !process.env.CIRCLECI,
  configureWebpack: {
    plugins: [
      new StyleLintPlugin({ emitErrors: false, syntax: 'scss' }),
    ],
  },
  chainWebpack: (config) => {
    const svgRule = config.module.rule('svg');

    svgRule.uses.clear();

    svgRule
      .oneOf('inline')
      .resourceQuery(/inline/)
      .use('vue-svg-loader')
      .loader('vue-svg-loader')
      .end()
      .end()
      .oneOf('external')
      .use('file-loader')
      .loader('file-loader')
      .options({ name: 'assets/[name].[hash:8].[ext]' });
  },
};

@haoqunjiang haoqunjiang added bug and removed needs reproduction This issue is missing a minimal runnable reproduction, provided by the author labels Aug 14, 2018
@haoqunjiang
Copy link
Member

As a workaround, always use chainWebpack.

The root cause here is that the merge strategy of webpack-merge (which calls lodash.mergeWith) strips off the private __ruleName property used by webpack-chain to stringify config contents.

https://github.com/mozilla-neutrino/webpack-chain/blob/255b4b5f21c70c4fe83844a3fc5ae1da57526b2b/src/Rule.js#L59-L61

@praburangki
Copy link

I had the same issue using this:
configureWebpack: {}

But it works if I change it to this:
configureWebpack: config => {}

@yyx990803 I believe this commit 2257034 fixed the issue. Will this be released soon?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants