mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-29 23:02:42 +00:00
feat(config, css): resolve packages exporting non js files
This commit is contained in:
commit
59c7c5b09d
@ -8,7 +8,7 @@
|
|||||||
<script>
|
<script>
|
||||||
<% if (loading) { %>import NuxtLoading from '<%= (typeof loading === "string" ? loading : "./components/nuxt-loading.vue") %>'<% } %>
|
<% if (loading) { %>import NuxtLoading from '<%= (typeof loading === "string" ? loading : "./components/nuxt-loading.vue") %>'<% } %>
|
||||||
<% css.forEach(function (c) { %>
|
<% css.forEach(function (c) { %>
|
||||||
import '<%= wp(c.src || c) %>'
|
import '<%= relativeToBuild(resolvePath(c.src || c)) %>'
|
||||||
<% }) %>
|
<% }) %>
|
||||||
|
|
||||||
let layouts = {
|
let layouts = {
|
||||||
|
@ -242,6 +242,7 @@ export default class Builder extends Tapable {
|
|||||||
hash,
|
hash,
|
||||||
r,
|
r,
|
||||||
wp,
|
wp,
|
||||||
|
resolvePath: this.nuxt.resolvePath.bind(this.nuxt),
|
||||||
relativeToBuild: this.relativeToBuild
|
relativeToBuild: this.relativeToBuild
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -5,6 +5,7 @@ import Renderer from './renderer'
|
|||||||
import Options from './options'
|
import Options from './options'
|
||||||
import Debug from 'debug'
|
import Debug from 'debug'
|
||||||
import enableDestroy from 'server-destroy'
|
import enableDestroy from 'server-destroy'
|
||||||
|
import Module from 'module'
|
||||||
import { join, resolve } from 'path'
|
import { join, resolve } from 'path'
|
||||||
|
|
||||||
const debug = Debug('nuxt:')
|
const debug = Debug('nuxt:')
|
||||||
@ -16,6 +17,9 @@ export default class Nuxt extends Tapable {
|
|||||||
|
|
||||||
this.options = Options(_options)
|
this.options = Options(_options)
|
||||||
|
|
||||||
|
// Paths for resolving requires from `rootDir`
|
||||||
|
this.nodeModulePaths = Module._nodeModulePaths(this.options.rootDir)
|
||||||
|
|
||||||
this.initialized = false
|
this.initialized = false
|
||||||
this.errorHandler = this.errorHandler.bind(this)
|
this.errorHandler = this.errorHandler.bind(this)
|
||||||
|
|
||||||
@ -101,7 +105,7 @@ export default class Nuxt extends Tapable {
|
|||||||
resolvePath (path) {
|
resolvePath (path) {
|
||||||
// Try to resolve using NPM resolve path first
|
// Try to resolve using NPM resolve path first
|
||||||
try {
|
try {
|
||||||
let resolvedPath = require.resolve(path)
|
let resolvedPath = Module._resolveFilename(path, { paths: this.nodeModulePaths })
|
||||||
return resolvedPath
|
return resolvedPath
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Just continue
|
// Just continue
|
||||||
|
Loading…
Reference in New Issue
Block a user