arco init yourProjectName 无法成功建立项目
seepine opened this issue · 10 comments
seepine commented
ZhongMingKun commented
+1
ZhongMingKun commented
暂时测试是 builder改为webpack5后可用
- 安装依赖
$ yarn add -D @storybook/builder-webpack5 @storybook/manager-webpack5
.storybook/main.js
里面加上core: { builder: 'webpack5' }
;
具体代码:
const path = require('path');
const glob = require('glob');
const fs = require('fs-extra');
const packagePaths = glob.sync('packages/*');
const lessRegex = /\.less$/;
const lessModuleRegex = /\.module\.less$/;
function getLoaderForStyle(cssOptions) {
return [
{
loader: 'style-loader',
},
{
loader: 'css-loader',
options: cssOptions,
},
{
loader: 'less-loader',
options: {
lessOptions: {
javascriptEnabled: true,
},
},
},
];
}
module.exports = {
+ core: { builder: 'webpack5' },
stories: ['../packages/**/stories/*.@(js|jsx|ts|tsx)'],
addons: ['@storybook/addon-links', '@storybook/addon-essentials'],
webpackFinal: (config) => {
// 为 storybook 添加 packages 中项目的 alias
packagePaths.forEach((_path) => {
const packageJson = fs.readJsonSync(path.resolve(_path, 'package.json'));
const dirSourceFile =
packageJson.arcoMeta && packageJson.arcoMeta.type === 'vue-library'
? 'components'
: 'src';
config.resolve.alias[`${packageJson.name}$`] = path.resolve(
_path,
dirSourceFile
);
});
// less
config.module.rules.push({
test: lessRegex,
exclude: lessModuleRegex,
use: getLoaderForStyle(),
});
// less css modules
config.module.rules.push({
test: lessModuleRegex,
use: getLoaderForStyle({ modules: true }),
});
// svg modules
config.module.rules.push({
test: /\.svg$/,
use: ['vue-loader', 'vue-svg-loader'],
});
return config;
},
};
- 运行
$ yarn dev
seepine commented
暂时测试是 builder改为webpack5后可用
- 安装依赖
$ yarn add -D @storybook/builder-webpack5 @storybook/manager-webpack5
- 运行
$ yarn dev
啊咧,我执行了你这句后运行,还是一样的错误
TypeError: Cannot read properties of undefined (reading 'get')
seepine commented
你arco init 是vue、组件库类型吗
ZhongMingKun commented
你arco init 是vue、组件库类型吗
回看下我的回复,添加了一下webpack5的使用
seepine commented
seepine commented
MisterLuffy commented
MisterLuffy commented
暂时测试是 builder改为webpack5后可用
- 安装依赖
$ yarn add -D @storybook/builder-webpack5 @storybook/manager-webpack5
.storybook/main.js
里面加上core: { builder: 'webpack5' }
;具体代码:
const path = require('path'); const glob = require('glob'); const fs = require('fs-extra'); const packagePaths = glob.sync('packages/*'); const lessRegex = /\.less$/; const lessModuleRegex = /\.module\.less$/; function getLoaderForStyle(cssOptions) { return [ { loader: 'style-loader', }, { loader: 'css-loader', options: cssOptions, }, { loader: 'less-loader', options: { lessOptions: { javascriptEnabled: true, }, }, }, ]; } module.exports = { + core: { builder: 'webpack5' }, stories: ['../packages/**/stories/*.@(js|jsx|ts|tsx)'], addons: ['@storybook/addon-links', '@storybook/addon-essentials'], webpackFinal: (config) => { // 为 storybook 添加 packages 中项目的 alias packagePaths.forEach((_path) => { const packageJson = fs.readJsonSync(path.resolve(_path, 'package.json')); const dirSourceFile = packageJson.arcoMeta && packageJson.arcoMeta.type === 'vue-library' ? 'components' : 'src'; config.resolve.alias[`${packageJson.name}$`] = path.resolve( _path, dirSourceFile ); }); // less config.module.rules.push({ test: lessRegex, exclude: lessModuleRegex, use: getLoaderForStyle(), }); // less css modules config.module.rules.push({ test: lessModuleRegex, use: getLoaderForStyle({ modules: true }), }); // svg modules config.module.rules.push({ test: /\.svg$/, use: ['vue-loader', 'vue-svg-loader'], }); return config; }, };
- 运行
$ yarn dev
试了一下确实可行,我们更新一下项目模板的配置到 Webpack 5。
azhengyongqin commented