Skip to content

Altering source import path #69

@gihrig

Description

@gihrig

I'm really liking ReactQL, You've hit a nice balance between out-of-the-box functionality and flexibility! 😄

So far, moving an existing project to ReactQL has been pretty painless.

I do have an issue I'm kind of stuck on at present though.

The original source project includes extensive configuration for Eslint, Prettier and Storybook. These use an import path which has ./src as the universal import path, rather than project root. So, imports look like this:

import GraphQLMessage from 'components/GraphQLMessage';

Rather than the ReactQL standard:

import GraphQLMessage from 'src/components/GraphQLMessage';

So I need to modify ReactQL or the existing project. I'm not opposed to modifying the existing project, but if there is an easy way to add src/ to the import path so components can just import ... from 'components/ComponentName' that would be preferable.

I have searched and found config/paths

  // Source path; where we'll put our application files
  src: path.join(root, 'src'),

which is used in ./kit/webpack/base.js and found:

  plugins: [
    // Options that our module loaders will pull from
    new webpack.LoaderOptionsPlugin({
...
      options: {

        // The 'context' that our loaders will use as the root folder
        context: PATHS.src,
...

I have fiddled with the config/paths.src setting, but that didn't seem to make a difference in the error I get when importing from 'components/...

Failed to compile.

Module not found: Error: Can't resolve 'components/GraphQLMessage'

Further webpack.LoaderOptionsPlugin seems to be deprecated as of webpack 2?

The LoaderOptionsPlugin ... is built for migration from webpack 1 to 2
...
This plugin will be removed in the future as it only exists for migration.

So I'm wondering if I'm totally off base in my search for a solution...

If there is a simple solution I would greatly appreciate that, if not, don't sweat it. I'm more familiar with the existing project and can modify that without too much difficulty.

Oops! found a solution just after posting this, see next.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions