我已经设置了一个新的 vue 项目并向该项目添加了故事书。当我有使用该@/components路径的组件时,它无法正确运行。
Can't resolve '@/components/EntityGrid/EntityGrid.Component.vue'
Run Code Online (Sandbox Code Playgroud)
我尝试了多个 webpack.config.js 但没有任何运气。解决这个问题最简单的 webpack.config.js 是什么
这是在没有 webpack.config.js 的默认配置中发生的。
toa*_*oza 10
我通过添加以下内容成功解决了这个问题.storybook/main.js
const path = require("path");
module.exports = {
stories: ['./../src/**/*.stories.(js|jsx|ts|tsx|mdx)'],
...
webpackFinal: async (config) => {
config.resolve.alias = {
...config.resolve.alias,
"@": path.resolve(__dirname, "../src/"),
};
// keep this if you're doing typescript
// config.resolve.extensions.push(".ts", ".tsx");
return config;
},
}
Run Code Online (Sandbox Code Playgroud)
以下是一些有用的链接,可帮助提供更多背景信息:
我不知道你的问题的原因是什么,但这是我的工作vue.config.js
const path = require('path')
module.exports = {
chainWebpack: config => {
config.module
.rule("i18n")
.resourceQuery(/blockType=i18n/)
.type('javascript/auto')
.use("i18n")
.loader("@kazupon/vue-i18n-loader")
.end();
},
configureWebpack: {
resolve: {
extensions: ['.js', '.vue', '.json'],
alias: {
'@': path.join(__dirname, '/src')
}
},
module: {
rules: [
{
test: /\.(graphql|gql)$/,
exclude: /node_modules/,
loader: 'graphql-tag/loader',
},
]
},
},
css: {
loaderOptions: {
sass: {
data: `@import "@/assets/sass/_variables.scss"; @import "@/assets/sass/_mixins.scss";`,
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
忽略所有你不需要的东西
| 归档时间: |
|
| 查看次数: |
3612 次 |
| 最近记录: |