diff --git a/packages/vue-cli-plugin-hbuilderx/build/webpack.nvue.conf.js b/packages/vue-cli-plugin-hbuilderx/build/webpack.nvue.conf.js index d6d01474d2f9975f521874ca52f39f025baee1a1..4415d1182fb8ef340aaec10db0184cc58a560514 100644 --- a/packages/vue-cli-plugin-hbuilderx/build/webpack.nvue.conf.js +++ b/packages/vue-cli-plugin-hbuilderx/build/webpack.nvue.conf.js @@ -135,7 +135,7 @@ const rules = [{ babelrc: false } }, - jsPreprocessorLoader + jsPreprocessorLoader ] // exclude (modulePath) { // nvue js均提供babel,否则还得提供transpileDependencies配置 // return excludeModuleReg.test(modulePath) && modulePath.indexOf('@dcloudio') === -1 diff --git a/packages/vue-cli-plugin-uni/commands/build.js b/packages/vue-cli-plugin-uni/commands/build.js index 9744264cfeeb4a94dfc27dfc5da69ab758ab5c98..0b64298d0bb05a97447db6204f06f545fa066de6 100644 --- a/packages/vue-cli-plugin-uni/commands/build.js +++ b/packages/vue-cli-plugin-uni/commands/build.js @@ -100,7 +100,7 @@ function getWebpackConfig (api, args, options) { modifyConfig(webpackConfig, config => { config.optimization.minimize = true if (webpack.version[0] <= 4) { - config.optimization.namedModules = false + config.optimization.namedModules = false } }) } else { @@ -109,7 +109,7 @@ function getWebpackConfig (api, args, options) { config.optimization = {} } if (webpack.version[0] <= 4) { - config.optimization.namedModules = false + config.optimization.namedModules = false } }) } diff --git a/packages/vue-cli-plugin-uni/commands/serve.js b/packages/vue-cli-plugin-uni/commands/serve.js index b2d04db4a9d9ca4a305dcac24405f7f39e8859ee..7bd7f4b14ea3504a8d199e81105e662b7a2d52b1 100644 --- a/packages/vue-cli-plugin-uni/commands/serve.js +++ b/packages/vue-cli-plugin-uni/commands/serve.js @@ -172,8 +172,8 @@ module.exports = (api, options) => { // launch editor support. // this works with vue-devtools & @vue/cli-overlay devServer.app.use('/__open-in-editor', launchEditorMiddleware(() => console.log( - `To specify an editor, specify the EDITOR env variable or ` + - `add "editor" field to your Vue project config.\n` + 'To specify an editor, specify the EDITOR env variable or ' + + 'add "editor" field to your Vue project config.\n' ))) // allow other plugins to register middlewares, e.g. PWA @@ -189,42 +189,42 @@ module.exports = (api, options) => { }), compiler) } else { server = new WebpackDevServer(compiler, Object.assign({ - clientLogLevel: 'none', - historyApiFallback: { - disableDotRule: true, - rewrites: [{ - from: /./, - to: path.posix.join(options.publicPath, 'index.html') - }] - }, - contentBase: api.resolve('public'), - watchContentBase: !isProduction, - hot: !isProduction, - quiet: true, - compress: isProduction, - publicPath: options.publicPath, - overlay: isProduction // TODO disable this - ? false : { - warnings: false, - errors: true - } - }, projectDevServerOptions, { - https: useHttps, - proxy: proxySettings, - before (app, server) { + clientLogLevel: 'none', + historyApiFallback: { + disableDotRule: true, + rewrites: [{ + from: /./, + to: path.posix.join(options.publicPath, 'index.html') + }] + }, + contentBase: api.resolve('public'), + watchContentBase: !isProduction, + hot: !isProduction, + quiet: true, + compress: isProduction, + publicPath: options.publicPath, + overlay: isProduction // TODO disable this + ? false : { + warnings: false, + errors: true + } + }, projectDevServerOptions, { + https: useHttps, + proxy: proxySettings, + before (app, server) { // launch editor support. // this works with vue-devtools & @vue/cli-overlay - app.use('/__open-in-editor', launchEditorMiddleware(() => console.log( - 'To specify an editor, sepcify the EDITOR env variable or ' + + app.use('/__open-in-editor', launchEditorMiddleware(() => console.log( + 'To specify an editor, sepcify the EDITOR env variable or ' + 'add "editor" field to your Vue project config.\n' - ))) - // allow other plugins to register middlewares, e.g. PWA - api.service.devServerConfigFns.forEach(fn => fn(app, server)) - // apply in project middlewares - projectDevServerOptions.before && projectDevServerOptions.before(app, - server) - } - })) + ))) + // allow other plugins to register middlewares, e.g. PWA + api.service.devServerConfigFns.forEach(fn => fn(app, server)) + // apply in project middlewares + projectDevServerOptions.before && projectDevServerOptions.before(app, + server) + } + })) } ; @@ -356,11 +356,11 @@ module.exports = (api, options) => { if (webpack.version[0] > 4) { server.start().catch(err => reject(err)) } else { - server.listen(port, host, err => { - if (err) { - reject(err) - } - }) + server.listen(port, host, err => { + if (err) { + reject(err) + } + }) } }) }) diff --git a/packages/vue-cli-plugin-uni/lib/app-plus/index.js b/packages/vue-cli-plugin-uni/lib/app-plus/index.js index 11224fcb5db46c19635904a3fbdb2968ff8c0dfc..88935bb52d3043667f7d6c279851986777b0edf4 100644 --- a/packages/vue-cli-plugin-uni/lib/app-plus/index.js +++ b/packages/vue-cli-plugin-uni/lib/app-plus/index.js @@ -139,7 +139,7 @@ const v3 = { filename: '[name].js', chunkFilename: '[id].js', // webpack5 use strict - globalObject: webpack.version[0] > 4 ? `(new Function("return this")())` : 'this' + globalObject: webpack.version[0] > 4 ? '(new Function("return this")())' : 'this' }, performance: { hints: false diff --git a/packages/vue-cli-plugin-uni/lib/configure-webpack.js b/packages/vue-cli-plugin-uni/lib/configure-webpack.js index f5e0784ba6691edecb7ae76eb3620aa95d00542d..4011c1193eaaa909b7d355717e7e8098c0bee019 100644 --- a/packages/vue-cli-plugin-uni/lib/configure-webpack.js +++ b/packages/vue-cli-plugin-uni/lib/configure-webpack.js @@ -70,15 +70,15 @@ module.exports = function configureWebpack (platformOptions, manifestPlatformOpt return rules.length > 0 && rule.use } else { const RuleSet = require('webpack/lib/RuleSet') - const normalized = RuleSet.normalizeRule(clone, {}, '') - return ( - !rule.enforce && + const normalized = RuleSet.normalizeRule(clone, {}, '') + return ( + !rule.enforce && normalized.resource && normalized.resource(fakeFile) - ) + ) + } } } - } function updateJsLoader (rawRules, fakeFile, checkLoaderRegex, loader) { const matchRule = rawRules.find(createMatcher(fakeFile)) @@ -185,18 +185,18 @@ module.exports = function configureWebpack (platformOptions, manifestPlatformOpt if (uses.find(use => babelLoaderRe.test(use.loader))) { const index = uses.findIndex(use => cacheLoaderRe.test(use.loader)) if (index >= 0) { - if (process.env.UNI_USING_CACHE) { - Object.assign(uses[index].options, api.genCacheConfig( - 'babel-loader/' + process.env.UNI_PLATFORM, - getPartialIdentifier() - )) - } else { - uses.splice(index, 1) + if (process.env.UNI_USING_CACHE) { + Object.assign(uses[index].options, api.genCacheConfig( + 'babel-loader/' + process.env.UNI_PLATFORM, + getPartialIdentifier() + )) + } else { + uses.splice(index, 1) + } } } } } - } // js preprocess updateJsLoader(rawRules, 'foo.js', babelLoaderRe, { diff --git a/packages/vue-cli-plugin-uni/lib/h5/cssnano-options.js b/packages/vue-cli-plugin-uni/lib/h5/cssnano-options.js index 8a783f9ae51daae4fa1450127f0af0db434cd681..3324d8c8a6f6157e97cab34c1a4236a78c18c71f 100644 --- a/packages/vue-cli-plugin-uni/lib/h5/cssnano-options.js +++ b/packages/vue-cli-plugin-uni/lib/h5/cssnano-options.js @@ -11,8 +11,8 @@ module.exports = function initCssnanoOptions (webpackConfig) { } const plugins = [require('cssnano')({ - preset: ['default', getPlatformCssnano()] - })] + preset: ['default', getPlatformCssnano()] + })] // TODO postcss-loader version > 4 if (webpack.version[0] > 4) {