ionic 3在发布版本中排除页面

时间:2018-12-11 09:47:34

标签: typescript ionic-framework ionic3 tsconfig

我正在尝试排除ionic版本(发行版)中的某些页面。所以我做了以下事情,

我在tsconfig.json的exclude属性中向页面添加了相对路径

"exclude": [
    "node_modules",
    "src/pages/job-order/*.ts"
  ],

这是我的tsconfig.json

 {
      "compilerOptions": {
        "allowSyntheticDefaultImports": true,
        "declaration": false,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "allowJs": true,
        "lib": [
          "dom",
          "es2015"
         ],
        "module": "es2015",
        "moduleResolution": "node",
        "sourceMap": true,
        "target": "es5"
      },
      "include": [
        "src/**/*.ts"
       ],
      "exclude": [
        "node_modules",
         "src/pages/job-order/*.ts"
       ],
      "compileOnSave": false,
      "atom": {
         "rewriteTsconfig": false
      }
    }

如果我做本地服务,它可以正常工作,没有任何错误。当我尝试发布版本时,它失败,但出现以下异常:

    [12:37:52]  ionic-app-scripts 3.1.0
    [12:37:52]  build dev started ...
    [12:37:52]  clean started ...
    [12:37:52]  clean finished in 3 ms
    [12:37:52]  copy started ...
    [12:37:52]  deeplinks started ...
    [12:37:52]  deeplinks finished in 19 ms
    [12:37:52]  ngc started ...
    [12:37:58]  ngc finished in 5.94 s
    [12:37:58]  preprocess started ...
    [12:37:58]  preprocess finished in less than 1 ms
    [12:37:58]  webpack started ...
    [12:37:58]  copy finished in 6.14 s
    [12:38:01]  ionic-app-script task: "build"
    [12:38:01]  Error: ./src lazy Module not found: Error: Can't resolve
                '/Users/appzui/MyIonicProject/src/pages/job-order/job- 
                order.module.ngfactory.js' in
                '/Users/appzui/MyIonicProject/src' resolve
                '/Users/appzui/MyIonicProject/src/pages/job-order/job- 
                order.module.ngfactory.js' in
                '/Users/appzui/MyIonicProject/src' using description file: 
                /Users/appzui/MyIonicProject/package.json
                (relative path: ./src) Field 'browser' doesn't contain a 
                valid alias configuration after using description
                file: /Users/appzui/MyIonicProject/package.json (relative 
                 path: ./src) using description file:
                /Users/appzui/MyIonicProject/package.json (relative path:
                ./src/pages/job-order/job-order.module.ngfactory.js) no 
                extension Field 'browser' doesn't contain a valid
                alias configuration 
                /Users/appzui/MyIonicProject/src/pages/job-order/job- 
                order.module.ngfactory.js doesn't
                exist .ts Field 'browser' doesn't contain a valid alias 
                configuration
                /Users/appzui/MyIonicProject/src/pages/job-order/job- 
                order.module.ngfactory.js.ts doesn't exist .js Field
                'browser' doesn't contain a valid alias configuration
                /Users/appzui/MyIonicProject/src/pages/job-order/job- 
                order.module.ngfactory.js.js doesn't exist .json Field
                'browser' doesn't contain a valid alias configuration
                /Users/appzui/MyIonicProject/src/pages/job-order/job- 
                order.module.ngfactory.js.json doesn't exist as
                directory /Users/appzui/MyIonicProject/src/pages/job- 
                order/job-order.module.ngfactory.js doesn't exist
                [/Users/appzui/MyIonicProject/src/pages/job-order/job- 
                order.module.ngfactory.js]
                [/Users/appzui/MyIonicProject/src/pages/job-order/job- 
                order.module.ngfactory.js.ts]
                [/Users/appzui/MyIonicProject/src/pages/job-order/job- 
                order.module.ngfactory.js.js]
                [/Users/appzui/MyIonicProject/src/pages/job-order/job- 
                order.module.ngfactory.js.json]
                [/Users/appzui/MyIonicProject/src/pages/job-order/job- 
                order.module.ngfactory.js] @ ./src lazy @
                ./node_modules/ionic-angular/util/ng-module-loader.js @ 
                ./src/app/app.module.ngfactory.js @
                ./src/app/main.ts
                Error: ./src lazy
                Module not found: Error: Can't resolve 
                '/Users/appzui/MyIonicProject/src/pages/job-order/job- 
                order.module.ngfactory.js' in 
                '/Users/appzui/MyIonicProject/src'
                resolve '/Users/appzui/MyIonicProject/src/pages/job- 
                order/job-order.module.ngfactory.js' in 
                '/Users/appzui/MyIonicProject/src'
                using description file: 
                /Users/appzui/MyIonicProject/package.json (relative path: 
                ./src)
                Field 'browser' doesn't contain a valid alias configuration
                after using description file: 
                /Users/appzui/MyIonicProject/package.json (relative path: 
                ./src)
                using description file: 
                /Users/appzui/MyIonicProject/package.json (relative path: 
                ./src/pages/job-order/job-order.module.ngfactory.js)
                no extension
                Field 'browser' doesn't contain a valid alias configuration
                /Users/appzui/MyIonicProject/src/pages/job-order/job- 
                order.module.ngfactory.js doesn't exist
                .ts
                Field 'browser' doesn't contain a valid alias configuration
                /Users/appzui/MyIonicProject/src/pages/job-order/job- 
                order.module.ngfactory.js.ts doesn't exist
                .js
                Field 'browser' doesn't contain a valid alias configuration
                /Users/appzui/MyIonicProject/src/pages/job-order/job- 
                order.module.ngfactory.js.js doesn't exist
                .json
                Field 'browser' doesn't contain a valid alias configuration
                /Users/appzui/MyIonicProject/src/pages/job-order/job- 
                order.module.ngfactory.js.json doesn't exist
                as directory
                /Users/appzui/MyIonicProject/src/pages/job-order/job- 
                order.module.ngfactory.js doesn't exist
                [/Users/appzui/MyIonicProject/src/pages/job-order/job- 
                order.module.ngfactory.js]
                [/Users/appzui/MyIonicProject/src/pages/job-order/job- 
                order.module.ngfactory.js.ts]
                [/Users/appzui/MyIonicProject/src/pages/job-order/job- 
                order.module.ngfactory.js.js]
                [/Users/appzui/MyIonicProject/src/pages/job-order/job- 
                order.module.ngfactory.js.json]
                [/Users/appzui/MyIonicProject/src/pages/job-order/job- 
                order.module.ngfactory.js]
                @ ./src lazy
                @ ./node_modules/ionic-angular/util/ng-module-loader.js
                @ ./src/app/app.module.ngfactory.js
                @ ./src/app/main.ts
                at new BuildError 
                (/Users/appzui/MyIonicProject/node_modules/@ionic/app- 
                scripts/dist/util/errors.js:16:28)
                at callback 
                (/Users/appzui/MyIonicProject/node_modules/@ionic/app- 
                scripts/dist/webpack.js:121:28)
                at emitRecords.err 




   /Users/appzui/MyIonicProject/node_modules/webpack/lib/Compiler.js:265:13
              at Compiler.emitRecords 
         /Users/appzui/MyIonicProject/node_modules/webpack/lib/Compiler.js:371:38
            at emitAssets.err 
        /Users/appzui/MyIonicProject/node_modules/webpack/lib/Compiler.js:258:10
            at applyPluginsAsyncSeries1.err 
        /Users/appzui/MyIonicProject/node_modules/webpack/lib/Compiler.js:364:12
         at next 
        /Users/appzui/MyIonicProject/node_modules/tapable/lib/Tapable.js:218:11
            at Compiler.compiler.plugin 

        /Users/appzui/MyIonicProject/node_modules/webpack/lib/performance/SizeLimi 
             tsPlugin.js:99:4
         at Compiler.applyPluginsAsyncSeries1 
        /Users/appzui/MyIonicProject/node_modules/tapable/lib/Tapable.js:222:13)
         at Compiler.afterEmit 
        /Users/appzui/MyIonicProject/node_modules/webpack/lib/Compiler.js:361:9)
        npm ERR! code ELIFECYCLE
        npm ERR! errno 1
        npm ERR! MyIonicProject@0.0.1 build:release: ionic-app-scripts build -- 
        aot --minifycss --generateSourceMap true && cordova build browser -- 
        release
        npm ERR! Exit status 1
        npm ERR!
        npm ERR! Failed at the MyIonicProject@0.0.1 build:release script.
        npm ERR! This is probably not a problem with npm. There is likely 
        additional logging output above.

        npm ERR! A complete log of this run can be found in:
        npm ERR!     /Users/appzui/.npm/_logs/2018-12-11T07_08_01_789Z- 
        debug.log

离子信息:

 cli packages: (/usr/local/lib/node_modules)

       @ionic/cli-utils  : 1.9.2
       ionic (Ionic CLI) : 3.9.2

    global packages:

       Cordova CLI : 8.0.0

    local packages:

       @ionic/app-scripts : 3.1.0
       Cordova Platforms  : browser 5.0.4
       Ionic Framework    : ionic-angular 3.9.2

    System:

       Android SDK Tools : 26.1.1
       ios-deploy        : 1.9.2
       Node              : v9.4.0
       npm               : 6.4.1
       OS                : macOS High Sierra
       Xcode             : Xcode 9.3 Build version 9E145

其他信息: 在排除属性中添加页面路径后,我收到了实验装饰器警告,但在tsconfig.json上,experimentalDecorators设置为true。

请帮助我解决此问题

0 个答案:

没有答案