Skip to content

Commit

Permalink
Upgrate style loader (#2242)
Browse files Browse the repository at this point in the history
  • Loading branch information
smondal authored and gauravtiwari committed Sep 18, 2019
1 parent 3c394fc commit 2cef2fd
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 16 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -44,7 +44,7 @@
"postcss-safe-parser": "^4.0.1",
"regenerator-runtime": "^0.13.2",
"sass-loader": "^7.1.0",
"style-loader": "^0.23.1",
"style-loader": "^1.0.0",
"terser-webpack-plugin": "^1.3.0",
"webpack": "^4.34.0",
"webpack-assets-manifest": "^3.1.1",
Expand Down
9 changes: 9 additions & 0 deletions package/utils/__tests__/get_style_rule.js
Expand Up @@ -44,6 +44,15 @@ describe('getStyleRule', () => {
expect(cssRule.use).toMatchObject(expect.arrayContaining(expectation))
})

test('adds style-loader when extract_css is true', () => {
const expectation = [{loader: 'style-loader'}]

require('../../config').extract_css = false
const cssRule = getStyleRule(/\.(css)$/i)

expect(cssRule.use).toMatchObject(expect.objectContaining(expectation))
})

test(`doesn't add mini-css-extract-plugin when extract_css is false`, () => {
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const expectation = [MiniCssExtractPlugin.loader]
Expand Down
10 changes: 1 addition & 9 deletions package/utils/get_style_rule.js
@@ -1,17 +1,9 @@
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const { resolve } = require('path')
const devServer = require('../dev_server')
const config = require('../config')

const inDevServer = process.argv.find(v => v.includes('webpack-dev-server'))
const isHMR = inDevServer && (devServer && devServer.hmr)

const styleLoader = {
loader: 'style-loader',
options: {
hmr: isHMR,
sourceMap: true
}
loader: 'style-loader'
}

const getStyleRule = (test, modules = false, preprocessors = []) => {
Expand Down
20 changes: 14 additions & 6 deletions yarn.lock
Expand Up @@ -6867,6 +6867,14 @@ schema-utils@^1.0.0:
ajv-errors "^1.0.0"
ajv-keywords "^3.1.0"

schema-utils@^2.0.1:
version "2.1.0"
resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-2.1.0.tgz#940363b6b1ec407800a22951bdcc23363c039393"
integrity sha512-g6SViEZAfGNrToD82ZPUjq52KUPDYc+fN5+g6Euo5mLokl/9Yx14z0Cu4RR1m55HtBXejO0sBt+qw79axN+Fiw==
dependencies:
ajv "^6.1.0"
ajv-keywords "^3.1.0"

scss-tokenizer@^0.2.3:
version "0.2.3"
resolved "https://registry.yarnpkg.com/scss-tokenizer/-/scss-tokenizer-0.2.3.tgz#8eb06db9a9723333824d3f5530641149847ce5d1"
Expand Down Expand Up @@ -7298,13 +7306,13 @@ strip-json-comments@^2.0.1, strip-json-comments@~2.0.1:
resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a"
integrity sha1-PFMZQukIwml8DsNEhYwobHygpgo=

style-loader@^0.23.1:
version "0.23.1"
resolved "https://registry.yarnpkg.com/style-loader/-/style-loader-0.23.1.tgz#cb9154606f3e771ab6c4ab637026a1049174d925"
integrity sha512-XK+uv9kWwhZMZ1y7mysB+zoihsEj4wneFWAS5qoiLwzW0WzSqMrrsIy+a3zkQJq0ipFtBpX5W3MqyRIBF/WFGg==
style-loader@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/style-loader/-/style-loader-1.0.0.tgz#1d5296f9165e8e2c85d24eee0b7caf9ec8ca1f82"
integrity sha512-B0dOCFwv7/eY31a5PCieNwMgMhVGFe9w+rh7s/Bx8kfFkrth9zfTZquoYvdw8URgiqxObQKcpW51Ugz1HjfdZw==
dependencies:
loader-utils "^1.1.0"
schema-utils "^1.0.0"
loader-utils "^1.2.3"
schema-utils "^2.0.1"

stylehacks@^4.0.0:
version "4.0.3"
Expand Down

0 comments on commit 2cef2fd

Please sign in to comment.