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

Not working with vue-cli #6

Open
p-kuen opened this issue Dec 17, 2018 · 0 comments
Open

Not working with vue-cli #6

p-kuen opened this issue Dec 17, 2018 · 0 comments

Comments

@p-kuen
Copy link

p-kuen commented Dec 17, 2018

I really want to use that package with my vue-cli configuration.
Sadly it is not possible/does not work.

I implemented the transformer like this (because I know no other possibility with webpack-chain)

// vue.config.js

function graphqltransformer() {}
graphqltransformer.__expression = `() => ({before: [require('` + require.resolve('ts-transform-graphql-tag') + `').getTransformer()]})`

module.exports = {
  // ...
  chainWebpack: config => {
    // ...
    config.module
      .rule('ts')
      .use('ts-loader')
      .tap(options => {
        options.getCustomTransformers = graphqltransformer
        return options
      })
    config.module
      .rule('tsx')
      .use('ts-loader')
      .tap(options => {
        options.getCustomTransformers = graphqltransformer
        return options
      })
  }
}

The generated webpack.config.js looks quite good:

// ...
          /* config.module.rule('ts').use('ts-loader') */
          {
            loader: 'ts-loader',
            options: {
              transpileOnly: true,
              appendTsSuffixTo: [
                '\\.vue$'
              ],
              happyPackMode: false,
              getCustomTransformers: () => ({before: [require('/home/patrick/dev/bodnet/node_modules/ts-transform-graphql-tag/dist/index.js').getTransformer()]})
            }
          }
// ...

But when I build the project using yarn build the gql tags are strings like before.

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

No branches or pull requests

1 participant