Ejemplo n.º 1
0
 /// <summary>
 /// 在spa闭包中使用此函数来启动一个vue服务
 /// </summary>
 /// <param name="spaBuilder">Spa服务构建器</param>
 /// <param name="npmScript">npm脚本名称</param>
 /// <param name="compiledSuccessfullyString">用于判断服务启动完成的字符串</param>
 /// <exception cref="ArgumentNullException"></exception>
 /// <exception cref="InvalidOperationException"></exception>
 public static void UseVueDevelopmentServer(
     this ISpaBuilder spaBuilder,
     string npmScript,
     string compiledSuccessfullyString = null)
 {
     if (spaBuilder == null)
     {
         throw new ArgumentNullException(nameof(spaBuilder));
     }
     if (string.IsNullOrEmpty(spaBuilder.Options.SourcePath))
     {
         throw new InvalidOperationException("在使用UseVueDevelopmentServer之前必须在UseSpa闭包中为SpaOptions.SourcePath属性设置一个非空的值.");
     }
     VueDevelopmentServerMiddleware.Attach(spaBuilder, npmScript, compiledSuccessfullyString);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Handles requests by passing them through to an instance of the create-react-app server.
        /// This means you can always serve up-to-date CLI-built resources without having
        /// to run the create-react-app server manually.
        ///
        /// This feature should only be used in development. For production deployments, be
        /// sure not to enable the create-react-app server.
        /// </summary>
        /// <param name="spaBuilder">The <see cref="ISpaBuilder"/>.</param>
        /// <param name="npmScript">The name of the script in your package.json file that launches the create-react-app server.</param>
        public static void UseVueDevelopmentServer(
            this ISpaBuilder spaBuilder,
            string npmScript)
        {
            if (spaBuilder == null)
            {
                throw new ArgumentNullException(nameof(spaBuilder));
            }

            var spaOptions = spaBuilder.Options;

            if (string.IsNullOrEmpty(spaOptions.SourcePath))
            {
                throw new InvalidOperationException(
                          $"To use {nameof(UseVueDevelopmentServer)}, you must supply a non-empty value for the {nameof(SpaOptions.SourcePath)} property of {nameof(SpaOptions)} when calling {nameof(SpaApplicationBuilderExtensions.UseSpa)}.");
            }

            VueDevelopmentServerMiddleware.Attach(spaBuilder, npmScript);
        }