sorrycc / sekiro

A framework based on umi. (demo only)
10 stars 1 forks source link

有几个问题,不知道是不是我用法错误。 #1

Open xiaohuoni opened 5 years ago

xiaohuoni commented 5 years ago

问题一:options并没有透传数据,配置可以通过api.config取到 https://github.com/sorrycc/sekiro/blob/bbfc1dd87f8ba0550f69c4561506ab9a6f63abd5/plugin.js#L2

export default {
  antd: true,
};

问题二:配置antd提示错误

watch handler failed, since ".umirc.js" 中配置的 "antd" 并非约定的配置项,请选择 "chainWebpack, context, disableRedirectHoist, exportStatic, outputPath, plugins, routes, runtimePublicPath, singular, treeShaking, base, mountElementId, mock, history, alias, autoprefixer, babel, browserslist, chainConfig, copy, cssLoaderOptions, cssModulesExcludes, cssModulesWithAffix, cssnano, cssPublicPath, define, devServer, devtool, disableCSSModules, disableCSSSourceMap, disableDynamicImport, env, es5ImcompatibleVersions, externals, extraBabelIncludes, extraBabelPlugins, extraBabelPresets, extraPostCSSPlugins, hash, ignoreMomentLocale, lessLoaderOptions, manifest, minimizer, proxy, publicPath, sass, terserJSOptions, theme, tsConfigFile, typescript, uglifyJSOptions, urlLoaderExcludes, mountElementId, targets, dva" 中的一项

解决方法:通过_registerConfig配置,但文档里面不推荐

 api._registerConfig(() => {
    return () => {
      return {
        name: 'antd',
        validate: () => true,
        onChange(newConfig) {
          api.service.restart(`antd changed`);
        },
      };
    };
  });

demo:https://github.com/xiaohuoni/sekiro

sorrycc commented 5 years ago
  1. 这两个是同一个问题?为啥要配 antd: true?
  2. _registerConfig
xiaohuoni commented 5 years ago

options 获取不到.umirc.js的配置,antd:true 这里只是演示,没有实际意义。 .umirc.js 配置完,只能从api.config里面取到值

xiaohuoni commented 5 years ago

@sorrycc cc