我有一个基于vue-cli 3的新项目,在src/
文件夹中有.graphql
文件,例如:
#import "./track-list-fragment.graphql"
query ListTracks(
$sortBy: String
$order: String
$limit: Int
$nextToken: String
) {
listTracks(
sortBy: $sortBy
order: $order
limit: $limit
nextToken: $nextToken
) {
items {
...TrackListDetails
}
nextToken
}
}
当我运行yarn serve
时,它抱怨没有GraphQL的加载程序:
Module parse failed: Unexpected character '#' (1:0)
You may need an appropriate loader to handle this file type.
> #import "./track-list-fragment.graphql"
|
| query ListTracks(
但我确实已经正确设置了我的vue.config.js
(我想是这样的):
const webpack = require('webpack');
const path = require('path');
module.exports = {
configureWebpack: {
resolve: {
alias: {
$scss: path.resolve('src/assets/styles'),
},
},
plugins: [
new webpack.LoaderOptionsPlugin({
test: /\.graphql$/,
loader: 'graphql-tag/loader',
}),
],
},
};
我该如何解决这个问题?