mirror of
https://github.com/nuxt/nuxt.git
synced 2024-12-03 19:07:15 +00:00
feat: add styleExtensions (#4671)
This commit is contained in:
parent
7dd33fedd2
commit
471a32a1a8
@ -42,6 +42,7 @@ export default () => ({
|
|||||||
store: 'store'
|
store: 'store'
|
||||||
},
|
},
|
||||||
extensions: [],
|
extensions: [],
|
||||||
|
styleExtensions: ['css', 'pcss', 'postcss', 'styl', 'stylus', 'scss', 'sass', 'less'],
|
||||||
|
|
||||||
// Ignores
|
// Ignores
|
||||||
ignorePrefix: '-',
|
ignorePrefix: '-',
|
||||||
|
@ -46,7 +46,7 @@ export default class Resolver {
|
|||||||
return resolve(this.options.srcDir, path)
|
return resolve(this.options.srcDir, path)
|
||||||
}
|
}
|
||||||
|
|
||||||
resolvePath(path, { alias, module } = {}) {
|
resolvePath(path, { alias, module, isStyle } = {}) {
|
||||||
// Fast return in case of path exists
|
// Fast return in case of path exists
|
||||||
if (fs.existsSync(path)) {
|
if (fs.existsSync(path)) {
|
||||||
return path
|
return path
|
||||||
@ -80,8 +80,10 @@ export default class Resolver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const extensions = isStyle ? this.options.styleExtensions : this.options.extensions
|
||||||
|
|
||||||
// Check if any resolvedPath.[ext] or resolvedPath/index.[ext] exists
|
// Check if any resolvedPath.[ext] or resolvedPath/index.[ext] exists
|
||||||
for (const ext of this.options.extensions) {
|
for (const ext of extensions) {
|
||||||
if (!isDirectory && fs.existsSync(resolvedPath + '.' + ext)) {
|
if (!isDirectory && fs.existsSync(resolvedPath + '.' + ext)) {
|
||||||
return resolvedPath + '.' + ext
|
return resolvedPath + '.' + ext
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
<% 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((c) => { %>
|
<% css.forEach((c) => { %>
|
||||||
import '<%= relativeToBuild(resolvePath(c.src || c)) %>'
|
import '<%= relativeToBuild(resolvePath(c.src || c, { isStyle: true })) %>'
|
||||||
<% }) %>
|
<% }) %>
|
||||||
|
|
||||||
<%= Object.keys(layouts).map((key) => {
|
<%= Object.keys(layouts).map((key) => {
|
||||||
|
2
test/fixtures/with-config/nuxt.config.js
vendored
2
test/fixtures/with-config/nuxt.config.js
vendored
@ -80,7 +80,7 @@ export default {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
css: [{ src: '~/assets/app.pcss' }],
|
css: [{ src: '~/assets/app' }],
|
||||||
render: {
|
render: {
|
||||||
csp: true,
|
csp: true,
|
||||||
http2: {
|
http2: {
|
||||||
|
Loading…
Reference in New Issue
Block a user