feat: add styleExtensions (#4671)

This commit is contained in:
Alexander Lichter 2019-01-02 22:30:19 +01:00 committed by Pooya Parsa
parent 7dd33fedd2
commit 471a32a1a8
4 changed files with 7 additions and 4 deletions

View File

@ -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: '-',

View File

@ -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
} }

View File

@ -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) => {

View File

@ -80,7 +80,7 @@ export default {
}) })
} }
}, },
css: [{ src: '~/assets/app.pcss' }], css: [{ src: '~/assets/app' }],
render: { render: {
csp: true, csp: true,
http2: { http2: {