mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-30 09:27:13 +00:00
feat: upgrade css-loader to v3 (#5929)
This commit is contained in:
parent
de526f6d44
commit
3195f34531
@ -7,9 +7,10 @@ const config: NuxtConfiguration = {
|
|||||||
manualInject: true
|
manualInject: true
|
||||||
},
|
},
|
||||||
css: {
|
css: {
|
||||||
modules: true,
|
modules: {
|
||||||
importLoaders: 1,
|
|
||||||
localIdentName: '[local]_[hash:base64:5]'
|
localIdentName: '[local]_[hash:base64:5]'
|
||||||
|
},
|
||||||
|
importLoaders: 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,9 @@ export default () => ({
|
|||||||
},
|
},
|
||||||
css: {},
|
css: {},
|
||||||
cssModules: {
|
cssModules: {
|
||||||
|
modules: {
|
||||||
localIdentName: '[local]_[hash:base64:5]'
|
localIdentName: '[local]_[hash:base64:5]'
|
||||||
|
}
|
||||||
},
|
},
|
||||||
less: {},
|
less: {},
|
||||||
sass: {
|
sass: {
|
||||||
|
@ -65,7 +65,9 @@ Object {
|
|||||||
"sourceMap": false,
|
"sourceMap": false,
|
||||||
},
|
},
|
||||||
"cssModules": Object {
|
"cssModules": Object {
|
||||||
|
"modules": Object {
|
||||||
"localIdentName": "[local]_[hash:base64:5]",
|
"localIdentName": "[local]_[hash:base64:5]",
|
||||||
|
},
|
||||||
"sourceMap": false,
|
"sourceMap": false,
|
||||||
},
|
},
|
||||||
"file": Object {},
|
"file": Object {},
|
||||||
|
@ -50,8 +50,10 @@ Object {
|
|||||||
"loaders": Object {
|
"loaders": Object {
|
||||||
"css": Object {},
|
"css": Object {},
|
||||||
"cssModules": Object {
|
"cssModules": Object {
|
||||||
|
"modules": Object {
|
||||||
"localIdentName": "[local]_[hash:base64:5]",
|
"localIdentName": "[local]_[hash:base64:5]",
|
||||||
},
|
},
|
||||||
|
},
|
||||||
"file": Object {},
|
"file": Object {},
|
||||||
"fontUrl": Object {
|
"fontUrl": Object {
|
||||||
"limit": 1000,
|
"limit": 1000,
|
||||||
@ -390,8 +392,10 @@ Object {
|
|||||||
"loaders": Object {
|
"loaders": Object {
|
||||||
"css": Object {},
|
"css": Object {},
|
||||||
"cssModules": Object {
|
"cssModules": Object {
|
||||||
|
"modules": Object {
|
||||||
"localIdentName": "[local]_[hash:base64:5]",
|
"localIdentName": "[local]_[hash:base64:5]",
|
||||||
},
|
},
|
||||||
|
},
|
||||||
"file": Object {},
|
"file": Object {},
|
||||||
"fontUrl": Object {
|
"fontUrl": Object {
|
||||||
"limit": 1000,
|
"limit": 1000,
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
"caniuse-lite": "^1.0.30000974",
|
"caniuse-lite": "^1.0.30000974",
|
||||||
"chalk": "^2.4.2",
|
"chalk": "^2.4.2",
|
||||||
"consola": "^2.7.1",
|
"consola": "^2.7.1",
|
||||||
"css-loader": "^2.1.1",
|
"css-loader": "^3.0.0",
|
||||||
"cssnano": "^4.1.10",
|
"cssnano": "^4.1.10",
|
||||||
"eventsource-polyfill": "^0.9.6",
|
"eventsource-polyfill": "^0.9.6",
|
||||||
"extract-css-chunks-webpack-plugin": "^4.5.2",
|
"extract-css-chunks-webpack-plugin": "^4.5.2",
|
||||||
@ -50,6 +50,9 @@
|
|||||||
"webpack-node-externals": "^1.7.2",
|
"webpack-node-externals": "^1.7.2",
|
||||||
"webpackbar": "^3.2.0"
|
"webpackbar": "^3.2.0"
|
||||||
},
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8.9.0"
|
||||||
|
},
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ export default class StyleLoader {
|
|||||||
return this.buildContext.buildOptions.extractCSS
|
return this.buildContext.buildOptions.extractCSS
|
||||||
}
|
}
|
||||||
|
|
||||||
get exportOnlyLocals() {
|
get onlyLocals() {
|
||||||
return Boolean(this.isServer && this.extractCSS)
|
return Boolean(this.isServer && this.extractCSS)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,10 +68,10 @@ export default class StyleLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
css(options) {
|
css(options) {
|
||||||
options.exportOnlyLocals = this.exportOnlyLocals
|
options.onlyLocals = this.onlyLocals
|
||||||
const cssLoader = { loader: 'css-loader', options }
|
const cssLoader = { loader: 'css-loader', options }
|
||||||
|
|
||||||
if (options.exportOnlyLocals) {
|
if (options.onlyLocals) {
|
||||||
return [cssLoader]
|
return [cssLoader]
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ export default class StyleLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cssModules(options) {
|
cssModules(options) {
|
||||||
return this.css(Object.assign(options, { modules: true }))
|
return this.css(options)
|
||||||
}
|
}
|
||||||
|
|
||||||
extract() {
|
extract() {
|
||||||
|
@ -34,8 +34,10 @@ describe('basic dev', () => {
|
|||||||
],
|
],
|
||||||
loaders: {
|
loaders: {
|
||||||
cssModules: {
|
cssModules: {
|
||||||
|
modules: {
|
||||||
localIdentName: '[hash:base64:6]'
|
localIdentName: '[hash:base64:6]'
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
extend({ module: { rules }, output: wpOutput }, { isClient, loaders }) {
|
extend({ module: { rules }, output: wpOutput }, { isClient, loaders }) {
|
||||||
if (isClient) {
|
if (isClient) {
|
||||||
@ -92,7 +94,7 @@ describe('basic dev', () => {
|
|||||||
'css', 'cssModules', 'less', 'sass', 'scss', 'stylus', 'ts', 'tsx', 'vueStyle'
|
'css', 'cssModules', 'less', 'sass', 'scss', 'stylus', 'ts', 'tsx', 'vueStyle'
|
||||||
)
|
)
|
||||||
const { cssModules, vue } = loadersOptions
|
const { cssModules, vue } = loadersOptions
|
||||||
expect(cssModules.localIdentName).toBe('[hash:base64:6]')
|
expect(cssModules.modules.localIdentName).toBe('[hash:base64:6]')
|
||||||
expect(vueLoader.options).toBe(vue)
|
expect(vueLoader.options).toBe(vue)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -208,7 +208,7 @@ describe('with-config', () => {
|
|||||||
const { headers } = await rp(url('/test'), {
|
const { headers } = await rp(url('/test'), {
|
||||||
resolveWithFullResponse: true
|
resolveWithFullResponse: true
|
||||||
})
|
})
|
||||||
expect(headers['server-timing']).toMatch(/total;dur=\d+;desc="Nuxt Server Time"/)
|
expect(headers['server-timing']).toMatch(/total;dur=\d+(\.\d+)?;desc="Nuxt Server Time"/)
|
||||||
})
|
})
|
||||||
|
|
||||||
// Close server and ask nuxt to stop listening to file changes
|
// Close server and ask nuxt to stop listening to file changes
|
||||||
|
64
yarn.lock
64
yarn.lock
@ -3113,7 +3113,7 @@ camelcase@^4.1.0:
|
|||||||
resolved "https://registry.npmjs.org/camelcase/-/camelcase-4.1.0.tgz#d545635be1e33c542649c69173e5de6acfae34dd"
|
resolved "https://registry.npmjs.org/camelcase/-/camelcase-4.1.0.tgz#d545635be1e33c542649c69173e5de6acfae34dd"
|
||||||
integrity sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0=
|
integrity sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0=
|
||||||
|
|
||||||
camelcase@^5.0.0, camelcase@^5.2.0, camelcase@^5.3.1:
|
camelcase@^5.0.0, camelcase@^5.3.1:
|
||||||
version "5.3.1"
|
version "5.3.1"
|
||||||
resolved "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320"
|
resolved "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320"
|
||||||
integrity sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==
|
integrity sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==
|
||||||
@ -3791,21 +3791,22 @@ css-has-pseudo@^0.10.0:
|
|||||||
postcss "^7.0.6"
|
postcss "^7.0.6"
|
||||||
postcss-selector-parser "^5.0.0-rc.4"
|
postcss-selector-parser "^5.0.0-rc.4"
|
||||||
|
|
||||||
css-loader@^2.1.1:
|
css-loader@^3.0.0:
|
||||||
version "2.1.1"
|
version "3.0.0"
|
||||||
resolved "https://registry.npmjs.org/css-loader/-/css-loader-2.1.1.tgz#d8254f72e412bb2238bb44dd674ffbef497333ea"
|
resolved "https://registry.npmjs.org/css-loader/-/css-loader-3.0.0.tgz#bdd48a4921eefedf1f0a55266585944d4e5efc63"
|
||||||
integrity sha512-OcKJU/lt232vl1P9EEDamhoO9iKY3tIjY5GU+XDLblAykTdgs6Ux9P1hTHve8nFKy5KPpOXOsVI/hIwi3841+w==
|
integrity sha512-WR6KZuCkFbnMhRrGPlkwAA7SSCtwqPwpyXJAPhotYkYsc0mKU9n/fu5wufy4jl2WhBw9Ia8gUQMIp/1w98DuPw==
|
||||||
dependencies:
|
dependencies:
|
||||||
camelcase "^5.2.0"
|
camelcase "^5.3.1"
|
||||||
icss-utils "^4.1.0"
|
cssesc "^3.0.0"
|
||||||
|
icss-utils "^4.1.1"
|
||||||
loader-utils "^1.2.3"
|
loader-utils "^1.2.3"
|
||||||
normalize-path "^3.0.0"
|
normalize-path "^3.0.0"
|
||||||
postcss "^7.0.14"
|
postcss "^7.0.17"
|
||||||
postcss-modules-extract-imports "^2.0.0"
|
postcss-modules-extract-imports "^2.0.0"
|
||||||
postcss-modules-local-by-default "^2.0.6"
|
postcss-modules-local-by-default "^3.0.2"
|
||||||
postcss-modules-scope "^2.1.0"
|
postcss-modules-scope "^2.1.0"
|
||||||
postcss-modules-values "^2.0.0"
|
postcss-modules-values "^3.0.0"
|
||||||
postcss-value-parser "^3.3.0"
|
postcss-value-parser "^4.0.0"
|
||||||
schema-utils "^1.0.0"
|
schema-utils "^1.0.0"
|
||||||
|
|
||||||
css-prefers-color-scheme@^3.1.1:
|
css-prefers-color-scheme@^3.1.1:
|
||||||
@ -5717,12 +5718,7 @@ iconv-lite@0.4.24, iconv-lite@^0.4.24, iconv-lite@^0.4.4, iconv-lite@~0.4.13:
|
|||||||
dependencies:
|
dependencies:
|
||||||
safer-buffer ">= 2.1.2 < 3"
|
safer-buffer ">= 2.1.2 < 3"
|
||||||
|
|
||||||
icss-replace-symbols@^1.1.0:
|
icss-utils@^4.0.0, icss-utils@^4.1.1:
|
||||||
version "1.1.0"
|
|
||||||
resolved "https://registry.npmjs.org/icss-replace-symbols/-/icss-replace-symbols-1.1.0.tgz#06ea6f83679a7749e386cfe1fe812ae5db223ded"
|
|
||||||
integrity sha1-Bupvg2ead0njhs/h/oEq5dsiPe0=
|
|
||||||
|
|
||||||
icss-utils@^4.1.0:
|
|
||||||
version "4.1.1"
|
version "4.1.1"
|
||||||
resolved "https://registry.npmjs.org/icss-utils/-/icss-utils-4.1.1.tgz#21170b53789ee27447c2f47dd683081403f9a467"
|
resolved "https://registry.npmjs.org/icss-utils/-/icss-utils-4.1.1.tgz#21170b53789ee27447c2f47dd683081403f9a467"
|
||||||
integrity sha512-4aFq7wvWyMHKgxsH8QQtGpvbASCf+eM3wPRLI6R+MgAnTCZ6STYsRvttLvRWK0Nfif5piF394St3HeJDaljGPA==
|
integrity sha512-4aFq7wvWyMHKgxsH8QQtGpvbASCf+eM3wPRLI6R+MgAnTCZ6STYsRvttLvRWK0Nfif5piF394St3HeJDaljGPA==
|
||||||
@ -8722,14 +8718,15 @@ postcss-modules-extract-imports@^2.0.0:
|
|||||||
dependencies:
|
dependencies:
|
||||||
postcss "^7.0.5"
|
postcss "^7.0.5"
|
||||||
|
|
||||||
postcss-modules-local-by-default@^2.0.6:
|
postcss-modules-local-by-default@^3.0.2:
|
||||||
version "2.0.6"
|
version "3.0.2"
|
||||||
resolved "https://registry.npmjs.org/postcss-modules-local-by-default/-/postcss-modules-local-by-default-2.0.6.tgz#dd9953f6dd476b5fd1ef2d8830c8929760b56e63"
|
resolved "https://registry.npmjs.org/postcss-modules-local-by-default/-/postcss-modules-local-by-default-3.0.2.tgz#e8a6561be914aaf3c052876377524ca90dbb7915"
|
||||||
integrity sha512-oLUV5YNkeIBa0yQl7EYnxMgy4N6noxmiwZStaEJUSe2xPMcdNc8WmBQuQCx18H5psYbVxz8zoHk0RAAYZXP9gA==
|
integrity sha512-jM/V8eqM4oJ/22j0gx4jrp63GSvDH6v86OqyTHHUvk4/k1vceipZsaymiZ5PvocqZOl5SFHiFJqjs3la0wnfIQ==
|
||||||
dependencies:
|
dependencies:
|
||||||
postcss "^7.0.6"
|
icss-utils "^4.1.1"
|
||||||
postcss-selector-parser "^6.0.0"
|
postcss "^7.0.16"
|
||||||
postcss-value-parser "^3.3.1"
|
postcss-selector-parser "^6.0.2"
|
||||||
|
postcss-value-parser "^4.0.0"
|
||||||
|
|
||||||
postcss-modules-scope@^2.1.0:
|
postcss-modules-scope@^2.1.0:
|
||||||
version "2.1.0"
|
version "2.1.0"
|
||||||
@ -8739,12 +8736,12 @@ postcss-modules-scope@^2.1.0:
|
|||||||
postcss "^7.0.6"
|
postcss "^7.0.6"
|
||||||
postcss-selector-parser "^6.0.0"
|
postcss-selector-parser "^6.0.0"
|
||||||
|
|
||||||
postcss-modules-values@^2.0.0:
|
postcss-modules-values@^3.0.0:
|
||||||
version "2.0.0"
|
version "3.0.0"
|
||||||
resolved "https://registry.npmjs.org/postcss-modules-values/-/postcss-modules-values-2.0.0.tgz#479b46dc0c5ca3dc7fa5270851836b9ec7152f64"
|
resolved "https://registry.npmjs.org/postcss-modules-values/-/postcss-modules-values-3.0.0.tgz#5b5000d6ebae29b4255301b4a3a54574423e7f10"
|
||||||
integrity sha512-Ki7JZa7ff1N3EIMlPnGTZfUMe69FFwiQPnVSXC9mnn3jozCRBYIxiZd44yJOV2AmabOo4qFf8s0dC/+lweG7+w==
|
integrity sha512-1//E5jCBrZ9DmRX+zCtmQtRSV6PV42Ix7Bzj9GbwJceduuf7IqP8MgeTXuRDHOWj2m0VzZD5+roFWDuU8RQjcg==
|
||||||
dependencies:
|
dependencies:
|
||||||
icss-replace-symbols "^1.1.0"
|
icss-utils "^4.0.0"
|
||||||
postcss "^7.0.6"
|
postcss "^7.0.6"
|
||||||
|
|
||||||
postcss-nesting@^7.0.0:
|
postcss-nesting@^7.0.0:
|
||||||
@ -8978,7 +8975,7 @@ postcss-selector-parser@^5.0.0, postcss-selector-parser@^5.0.0-rc.3, postcss-sel
|
|||||||
indexes-of "^1.0.1"
|
indexes-of "^1.0.1"
|
||||||
uniq "^1.0.1"
|
uniq "^1.0.1"
|
||||||
|
|
||||||
postcss-selector-parser@^6.0.0:
|
postcss-selector-parser@^6.0.0, postcss-selector-parser@^6.0.2:
|
||||||
version "6.0.2"
|
version "6.0.2"
|
||||||
resolved "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-6.0.2.tgz#934cf799d016c83411859e09dcecade01286ec5c"
|
resolved "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-6.0.2.tgz#934cf799d016c83411859e09dcecade01286ec5c"
|
||||||
integrity sha512-36P2QR59jDTOAiIkqEprfJDsoNrvwFei3eCqKd1Y0tUsBimsq39BLp7RD+JWny3WgB1zGhJX8XVePwm9k4wdBg==
|
integrity sha512-36P2QR59jDTOAiIkqEprfJDsoNrvwFei3eCqKd1Y0tUsBimsq39BLp7RD+JWny3WgB1zGhJX8XVePwm9k4wdBg==
|
||||||
@ -9017,11 +9014,16 @@ postcss-url@^8.0.0:
|
|||||||
postcss "^7.0.2"
|
postcss "^7.0.2"
|
||||||
xxhashjs "^0.2.1"
|
xxhashjs "^0.2.1"
|
||||||
|
|
||||||
postcss-value-parser@^3.0.0, postcss-value-parser@^3.2.3, postcss-value-parser@^3.3.0, postcss-value-parser@^3.3.1:
|
postcss-value-parser@^3.0.0, postcss-value-parser@^3.2.3, postcss-value-parser@^3.3.1:
|
||||||
version "3.3.1"
|
version "3.3.1"
|
||||||
resolved "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-3.3.1.tgz#9ff822547e2893213cf1c30efa51ac5fd1ba8281"
|
resolved "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-3.3.1.tgz#9ff822547e2893213cf1c30efa51ac5fd1ba8281"
|
||||||
integrity sha512-pISE66AbVkp4fDQ7VHBwRNXzAAKJjw4Vw7nWI/+Q3vuly7SNfgYXvm6i5IgFylHGK5sP/xHAbB7N49OS4gWNyQ==
|
integrity sha512-pISE66AbVkp4fDQ7VHBwRNXzAAKJjw4Vw7nWI/+Q3vuly7SNfgYXvm6i5IgFylHGK5sP/xHAbB7N49OS4gWNyQ==
|
||||||
|
|
||||||
|
postcss-value-parser@^4.0.0:
|
||||||
|
version "4.0.0"
|
||||||
|
resolved "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-4.0.0.tgz#99a983d365f7b2ad8d0f9b8c3094926eab4b936d"
|
||||||
|
integrity sha512-ESPktioptiSUchCKgggAkzdmkgzKfmp0EU8jXH+5kbIUB+unr0Y4CY9SRMvibuvYUBjNh1ACLbxqYNpdTQOteQ==
|
||||||
|
|
||||||
postcss-values-parser@^2.0.0, postcss-values-parser@^2.0.1:
|
postcss-values-parser@^2.0.0, postcss-values-parser@^2.0.1:
|
||||||
version "2.0.1"
|
version "2.0.1"
|
||||||
resolved "https://registry.npmjs.org/postcss-values-parser/-/postcss-values-parser-2.0.1.tgz#da8b472d901da1e205b47bdc98637b9e9e550e5f"
|
resolved "https://registry.npmjs.org/postcss-values-parser/-/postcss-values-parser-2.0.1.tgz#da8b472d901da1e205b47bdc98637b9e9e550e5f"
|
||||||
|
Loading…
Reference in New Issue
Block a user