diff --git a/lib/builder/webpack/base.config.js b/lib/builder/webpack/base.config.js index 48918a60bb..bc3b4b7390 100644 --- a/lib/builder/webpack/base.config.js +++ b/lib/builder/webpack/base.config.js @@ -47,24 +47,12 @@ export default function webpackBaseConfig ({ isClient, isServer }) { resolve: { extensions: ['.js', '.json', '.vue', '.ts'], alias: { - '@@': join(this.options.rootDir), - '@': join(this.options.srcDir), - '@static': join(this.options.srcDir, 'static'), - '@assets': join(this.options.srcDir, 'assets'), - '@plugins': join(this.options.srcDir, 'plugins'), - '@pages': join(this.options.srcDir, 'pages'), - '@components': join(this.options.srcDir, 'components'), - '@middleware': join(this.options.srcDir, 'middleware'), - // Legacy support '~': join(this.options.srcDir), + '~~': join(this.options.rootDir), + '@': join(this.options.srcDir), + '@@': join(this.options.rootDir), 'static': join(this.options.srcDir, 'static'), // use in template with - '~static': join(this.options.srcDir, 'static'), - 'assets': join(this.options.srcDir, 'assets'), // use in template with - '~assets': join(this.options.srcDir, 'assets'), - '~plugins': join(this.options.srcDir, 'plugins'), - '~pages': join(this.options.srcDir, 'pages'), - '~components': join(this.options.srcDir, 'components'), - '~middleware': join(this.options.srcDir, 'middleware') + 'assets': join(this.options.srcDir, 'assets') // use in template with }, modules: [ join(this.options.rootDir, 'node_modules'), diff --git a/lib/common/utils.js b/lib/common/utils.js index 14fb1665b7..37dcfadef2 100644 --- a/lib/common/utils.js +++ b/lib/common/utils.js @@ -96,14 +96,7 @@ export function r () { let args = Array.prototype.slice.apply(arguments) let lastArg = _.last(args) - if (lastArg.includes('@')) { - return wp(lastArg) - } - - if (lastArg.includes('~')) { - // eslint-disable-next-line no-console - console.warn('[nuxt] Aliases using `~` are deprecated, please use `@/` instead.', - lastArg, '->', lastArg.replace('~/', '@/').replace('~', '@/')) + if (lastArg.includes('@') || lastArg.includes('~')) { return wp(lastArg) } diff --git a/lib/core/nuxt.js b/lib/core/nuxt.js index 1c5dfbd95b..7293e60552 100644 --- a/lib/core/nuxt.js +++ b/lib/core/nuxt.js @@ -100,21 +100,16 @@ export default class Nuxt extends Tapable { resolvePath (path) { // Try to resolve using NPM resolve path first - // Fixes problems with scopped modules try { let resolvedPath = require.resolve(path) return resolvedPath } catch (e) { // Just continue } - - // Shorthand to resolve from project srcDir - if (path.indexOf('@') === 0 || path.indexOf('~') === 0) { - if (path.indexOf('~') === 0) { - // eslint-disable-next-line no-console - console.warn('[nuxt] Aliases using `~` are deprecated, please use `@/` instead.', - path, '->', path.replace('~/', '@/').replace('~', '@/')) - } + // Shorthand to resolve from project dirs + if (path.indexOf('@@') === 0 || path.indexOf('~~') === 0) { + return join(this.options.rootDir, path.substr(2)) + } else if (path.indexOf('@') === 0 || path.indexOf('~') === 0) { return join(this.options.srcDir, path.substr(1)) } return resolve(this.options.srcDir, path)