mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-23 06:05:11 +00:00
feat: add styleExtensions (#4671)
This commit is contained in:
parent
7dd33fedd2
commit
471a32a1a8
@ -42,6 +42,7 @@ export default () => ({
|
||||
store: 'store'
|
||||
},
|
||||
extensions: [],
|
||||
styleExtensions: ['css', 'pcss', 'postcss', 'styl', 'stylus', 'scss', 'sass', 'less'],
|
||||
|
||||
// Ignores
|
||||
ignorePrefix: '-',
|
||||
|
@ -46,7 +46,7 @@ export default class Resolver {
|
||||
return resolve(this.options.srcDir, path)
|
||||
}
|
||||
|
||||
resolvePath(path, { alias, module } = {}) {
|
||||
resolvePath(path, { alias, module, isStyle } = {}) {
|
||||
// Fast return in case of path exists
|
||||
if (fs.existsSync(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
|
||||
for (const ext of this.options.extensions) {
|
||||
for (const ext of extensions) {
|
||||
if (!isDirectory && fs.existsSync(resolvedPath + '.' + ext)) {
|
||||
return resolvedPath + '.' + ext
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
import Vue from 'vue'
|
||||
<% if (loading) { %>import NuxtLoading from '<%= (typeof loading === "string" ? loading : "./components/nuxt-loading.vue") %>'<% } %>
|
||||
<% css.forEach((c) => { %>
|
||||
import '<%= relativeToBuild(resolvePath(c.src || c)) %>'
|
||||
import '<%= relativeToBuild(resolvePath(c.src || c, { isStyle: true })) %>'
|
||||
<% }) %>
|
||||
|
||||
<%= 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: {
|
||||
csp: true,
|
||||
http2: {
|
||||
|
Loading…
Reference in New Issue
Block a user