Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't work in production build #53

Closed
pavellzubkov opened this issue Apr 6, 2019 · 4 comments
Closed

don't work in production build #53

pavellzubkov opened this issue Apr 6, 2019 · 4 comments

Comments

@pavellzubkov
Copy link

I make fork from vue-element-admin and then add exampte from ncform-demo on dashboard.
When run "npm run dev" ncform work fine, but when run "npm run build" and deploy it doesn't work.
May be needs some special settings for webpack? I can't see some errors...

@daniel-dx
Copy link
Collaborator

Got it, i will test the case as soon as possible

@daniel-dx
Copy link
Collaborator

I tested the production mode of the project created by vue-cli (webpack v4.28.4) is OK.

But the production mode of vue-element-admin(webpack 4.16.5) is problematic.

I guess it is a problem with webpack or some loaders, finally i found the root cause.

The following is the source code fragment of the ncform-common package.

widget:
                        t.widget ||
                        (function(e) {
                          var t = 'input';
                          switch (e) {
                            case 'boolean':
                              t = 'radio';
                              break;
                            case 'object':
                              t = 'object';
                              break;
                            case 'array':
                              t = 'array';
                              break;
                            default:
                              t = 'input';
                          }
                          return t;
                        })(r),

It is compiled into the following code in the vue-element-admin production mode.

widget: t.widget || "input",

This is the root cause.

So the solution is to explicitly declare the widget as shown below

      {
        type: "object",
        properties: {
          name: {
            type: "string"
          },
          gender: {
            type: "boolean",
            ui: {
              widget: "radio"
            }
          }
        },
        ui: {
          widget: "object",
          widgetConfig: {
            layout: "h"
          }
        }
      }

@daniel-dx
Copy link
Collaborator

daniel-dx commented Apr 7, 2019

The safest solution is to upgrade webpack and related loaders, but I had no luck to do it successfully for vue-element-admin.

@pavellzubkov
Copy link
Author

great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants