模块解析失败:使用 vue-loader 运行ning yarn 运行 故事书时出现意外字符“@”
Module parse failed: Unexpected character '@' while running yarn run storybook with vue-loader
yarn run storybook
失败,错误
具体细节是:
Module parse failed: Unexpected character '@'
File was processed with these loaders:
* ./node_modules/vue-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
故事书5.2.3
webpack 4.41.0
更新:
这导致我出现另一个错误
[Vue warn]: Failed to mount component: template or render function not
defined. found in
当我添加
时问题得到了解决
const path = require('path');
module.exports = async ({ config, mode }) => {
config.module.rules.push({
test: /\.ts$/,
exclude: /node_modules/,
use: [
{
loader: 'ts-loader',
options: {
appendTsSuffixTo: [/\.vue$/],
transpileOnly: true
},
}
],
});
return config;
};
并删除了之前的 vue-loader
部分。
尝试不同的选项后,在 .storybook/
文件夹中创建具有以下内容的 webpack.config.js
文件时错误得到解决。
const path = require('path');
module.exports = async ({ config, mode }) => {
config.module.rules.push({
test: /\.vue$/,
loader: require.resolve('vue-loader'),
include: path.resolve(__dirname, '../src/'),
});
return config;
};
重要的是像这样解析加载器插件 require.resolve('vue-loader') 然后 re-运行 纱线命令再次。
yarn run storybook
失败,错误
具体细节是:
Module parse failed: Unexpected character '@'
File was processed with these loaders:
* ./node_modules/vue-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
故事书5.2.3
webpack 4.41.0
更新:
这导致我出现另一个错误
[Vue warn]: Failed to mount component: template or render function not defined. found in
当我添加
时问题得到了解决const path = require('path');
module.exports = async ({ config, mode }) => {
config.module.rules.push({
test: /\.ts$/,
exclude: /node_modules/,
use: [
{
loader: 'ts-loader',
options: {
appendTsSuffixTo: [/\.vue$/],
transpileOnly: true
},
}
],
});
return config;
};
并删除了之前的 vue-loader
部分。
尝试不同的选项后,在 .storybook/
文件夹中创建具有以下内容的 webpack.config.js
文件时错误得到解决。
const path = require('path');
module.exports = async ({ config, mode }) => {
config.module.rules.push({
test: /\.vue$/,
loader: require.resolve('vue-loader'),
include: path.resolve(__dirname, '../src/'),
});
return config;
};
重要的是像这样解析加载器插件 require.resolve('vue-loader') 然后 re-运行 纱线命令再次。