css-loader 1.0.1 → 7.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2180 -270
- package/dist/cjs.js +5 -0
- package/dist/index.js +178 -0
- package/dist/options.json +218 -0
- package/dist/plugins/index.js +27 -0
- package/dist/plugins/postcss-icss-parser.js +113 -0
- package/dist/plugins/postcss-import-parser.js +293 -0
- package/dist/plugins/postcss-url-parser.js +356 -0
- package/dist/runtime/api.js +85 -0
- package/dist/runtime/getUrl.js +26 -0
- package/dist/runtime/noSourceMaps.js +5 -0
- package/dist/runtime/sourceMaps.js +16 -0
- package/dist/utils.js +1068 -0
- package/package.json +100 -40
- package/CHANGELOG.md +0 -190
- package/index.js +0 -5
- package/lib/compile-exports.js +0 -51
- package/lib/css-base.js +0 -76
- package/lib/getImportPrefix.js +0 -14
- package/lib/getLocalIdent.js +0 -23
- package/lib/loader.js +0 -144
- package/lib/localsLoader.js +0 -44
- package/lib/processCss.js +0 -244
- package/lib/url/escape.js +0 -16
- package/locals.js +0 -5
package/package.json
CHANGED
|
@@ -1,52 +1,112 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "css-loader",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"author": "Tobias Koppers @sokra",
|
|
5
|
-
"license": "MIT",
|
|
3
|
+
"version": "7.1.4",
|
|
6
4
|
"description": "css loader module for webpack",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": "webpack/css-loader",
|
|
7
|
+
"author": "Tobias Koppers @sokra",
|
|
8
|
+
"homepage": "https://github.com/webpack/css-loader",
|
|
9
|
+
"bugs": "https://github.com/webpack/css-loader/issues",
|
|
10
|
+
"funding": {
|
|
11
|
+
"type": "opencollective",
|
|
12
|
+
"url": "https://opencollective.com/webpack"
|
|
13
|
+
},
|
|
14
|
+
"main": "dist/cjs.js",
|
|
7
15
|
"engines": {
|
|
8
|
-
"node": ">=
|
|
16
|
+
"node": ">= 18.12.0"
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"start": "npm run build -- -w",
|
|
20
|
+
"clean": "del-cli dist",
|
|
21
|
+
"validate:runtime": "es-check es5 \"dist/runtime/**/*.js\"",
|
|
22
|
+
"prebuild": "npm run clean",
|
|
23
|
+
"build": "cross-env NODE_ENV=production babel src -d dist --copy-files",
|
|
24
|
+
"postbuild": "npm run validate:runtime",
|
|
25
|
+
"commitlint": "commitlint --from=main",
|
|
26
|
+
"security": "npm audit --production",
|
|
27
|
+
"lint:prettier": "prettier --cache --list-different .",
|
|
28
|
+
"lint:js": "eslint --cache .",
|
|
29
|
+
"lint:spelling": "cspell --cache --no-must-find-files --quiet \"**/*.*\"",
|
|
30
|
+
"lint": "npm-run-all -l -p \"lint:**\"",
|
|
31
|
+
"fix:js": "npm run lint:js -- --fix",
|
|
32
|
+
"fix:prettier": "npm run lint:prettier -- --write",
|
|
33
|
+
"fix": "npm-run-all -l fix:js fix:prettier",
|
|
34
|
+
"test:only": "cross-env NODE_ENV=test jest",
|
|
35
|
+
"test:watch": "npm run test:only -- --watch",
|
|
36
|
+
"test:coverage": "npm run test:only -- --collectCoverageFrom=\"src/**/*.js\" --coverage",
|
|
37
|
+
"pretest": "npm run lint",
|
|
38
|
+
"test": "npm run test:coverage",
|
|
39
|
+
"prepare": "husky && npm run build",
|
|
40
|
+
"release": "standard-version"
|
|
9
41
|
},
|
|
10
42
|
"files": [
|
|
11
|
-
"
|
|
12
|
-
"index.js",
|
|
13
|
-
"locals.js"
|
|
43
|
+
"dist"
|
|
14
44
|
],
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"icss-utils": "^2.1.0",
|
|
19
|
-
"loader-utils": "^1.0.2",
|
|
20
|
-
"lodash": "^4.17.11",
|
|
21
|
-
"postcss": "^6.0.23",
|
|
22
|
-
"postcss-modules-extract-imports": "^1.2.0",
|
|
23
|
-
"postcss-modules-local-by-default": "^1.2.0",
|
|
24
|
-
"postcss-modules-scope": "^1.1.0",
|
|
25
|
-
"postcss-modules-values": "^1.3.0",
|
|
26
|
-
"postcss-value-parser": "^3.3.0",
|
|
27
|
-
"source-list-map": "^2.0.0"
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"@rspack/core": "0.x || ^1.0.0 || ^2.0.0-0",
|
|
47
|
+
"webpack": "^5.27.0"
|
|
28
48
|
},
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
-
|
|
49
|
+
"peerDependenciesMeta": {
|
|
50
|
+
"@rspack/core": {
|
|
51
|
+
"optional": true
|
|
52
|
+
},
|
|
53
|
+
"webpack": {
|
|
54
|
+
"optional": true
|
|
55
|
+
}
|
|
36
56
|
},
|
|
37
|
-
"
|
|
38
|
-
"
|
|
57
|
+
"dependencies": {
|
|
58
|
+
"icss-utils": "^5.1.0",
|
|
59
|
+
"postcss": "^8.4.40",
|
|
60
|
+
"postcss-modules-extract-imports": "^3.1.0",
|
|
61
|
+
"postcss-modules-local-by-default": "^4.0.5",
|
|
62
|
+
"postcss-modules-scope": "^3.2.0",
|
|
63
|
+
"postcss-modules-values": "^4.0.0",
|
|
64
|
+
"postcss-value-parser": "^4.2.0",
|
|
65
|
+
"semver": "^7.6.3"
|
|
39
66
|
},
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
67
|
+
"devDependencies": {
|
|
68
|
+
"@babel/cli": "^7.24.8",
|
|
69
|
+
"@babel/core": "^7.25.2",
|
|
70
|
+
"@babel/preset-env": "^7.25.3",
|
|
71
|
+
"@commitlint/cli": "^19.3.0",
|
|
72
|
+
"@commitlint/config-conventional": "^19.2.2",
|
|
73
|
+
"@webpack-contrib/eslint-config-webpack": "^3.0.0",
|
|
74
|
+
"babel-jest": "^30.0.0",
|
|
75
|
+
"cross-env": "^7.0.3",
|
|
76
|
+
"cspell": "^8.13.1",
|
|
77
|
+
"del-cli": "^5.1.0",
|
|
78
|
+
"es-check": "^7.2.1",
|
|
79
|
+
"eslint": "^8.54.0",
|
|
80
|
+
"eslint-config-prettier": "^9.1.0",
|
|
81
|
+
"eslint-plugin-import": "^2.29.0",
|
|
82
|
+
"file-loader": "^6.2.0",
|
|
83
|
+
"husky": "^9.1.4",
|
|
84
|
+
"jest": "^30.0.0",
|
|
85
|
+
"jest-environment-jsdom": "^30.0.0",
|
|
86
|
+
"less": "^4.2.0",
|
|
87
|
+
"less-loader": "^12.2.0",
|
|
88
|
+
"lint-staged": "^15.2.8",
|
|
89
|
+
"memfs": "^4.11.1",
|
|
90
|
+
"mini-css-extract-plugin": "^2.9.0",
|
|
91
|
+
"npm-run-all": "^4.1.5",
|
|
92
|
+
"postcss-loader": "^8.1.1",
|
|
93
|
+
"postcss-preset-env": "^9.6.0",
|
|
94
|
+
"prettier": "^3.3.3",
|
|
95
|
+
"sass": "^1.77.8",
|
|
96
|
+
"sass-loader": "^14.2.1",
|
|
97
|
+
"standard-version": "^9.5.0",
|
|
98
|
+
"strip-ansi": "^6.0.0",
|
|
99
|
+
"style-loader": "^3.3.4",
|
|
100
|
+
"stylus": "^0.63.0",
|
|
101
|
+
"stylus-loader": "^8.1.0",
|
|
102
|
+
"url-loader": "^4.1.1",
|
|
103
|
+
"webpack": "^5.93.0"
|
|
48
104
|
},
|
|
49
|
-
"
|
|
50
|
-
|
|
51
|
-
|
|
105
|
+
"keywords": [
|
|
106
|
+
"webpack",
|
|
107
|
+
"css",
|
|
108
|
+
"loader",
|
|
109
|
+
"url",
|
|
110
|
+
"import"
|
|
111
|
+
]
|
|
52
112
|
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
# Change Log
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
|
-
|
|
5
|
-
<a name="1.0.1"></a>
|
|
6
|
-
## [1.0.1](https://github.com/webpack-contrib/css-loader/compare/v1.0.0...v1.0.1) (2018-10-29)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
### Bug Fixes
|
|
10
|
-
|
|
11
|
-
* **loader:** trim unquoted import urls ([#783](https://github.com/webpack-contrib/css-loader/issues/783)) ([21fcddf](https://github.com/webpack-contrib/css-loader/commit/21fcddf))
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
<a name="1.0.0"></a>
|
|
16
|
-
# [1.0.0](https://github.com/webpack-contrib/css-loader/compare/v0.28.11...v1.0.0) (2018-07-06)
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
### BREAKING CHANGES
|
|
20
|
-
|
|
21
|
-
* remove `minimize` option, use [`postcss-loader`](https://github.com/postcss/postcss-loader) with [`cssnano`](https://github.com/cssnano/cssnano) or use [`optimize-cssnano-plugin`](https://github.com/intervolga/optimize-cssnano-plugin) plugin
|
|
22
|
-
* remove `module` option, use `modules` option instead
|
|
23
|
-
* remove `camelcase` option, use `camelCase` option instead
|
|
24
|
-
* remove `root` option, use [`postcss-loader`](https://github.com/postcss/postcss-loader) with [`postcss-url`](https://github.com/postcss/postcss-url) plugin
|
|
25
|
-
* remove `alias` option, use [`resolve.alias`](https://webpack.js.org/configuration/resolve/) feature or use [`postcss-loader`](https://github.com/postcss/postcss-loader) with [`postcss-url`](https://github.com/postcss/postcss-url) plugin
|
|
26
|
-
* update `postcss` to `6` version
|
|
27
|
-
* minimum require `nodejs` version is `6.9`
|
|
28
|
-
* minimum require `webpack` version is `4`
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
<a name="0.28.11"></a>
|
|
33
|
-
## [0.28.11](https://github.com/webpack-contrib/css-loader/compare/v0.28.10...v0.28.11) (2018-03-16)
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
### Bug Fixes
|
|
37
|
-
|
|
38
|
-
* **lib/processCss:** don't check `mode` for `url` handling (`options.modules`) ([#698](https://github.com/webpack-contrib/css-loader/issues/698)) ([c788450](https://github.com/webpack-contrib/css-loader/commit/c788450))
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
<a name="0.28.10"></a>
|
|
43
|
-
## [0.28.10](https://github.com/webpack-contrib/css-loader/compare/v0.28.9...v0.28.10) (2018-02-22)
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
### Bug Fixes
|
|
47
|
-
|
|
48
|
-
* **getLocalIdent:** add `rootContext` support (`webpack >= v4.0.0`) ([#681](https://github.com/webpack-contrib/css-loader/issues/681)) ([9f876d2](https://github.com/webpack-contrib/css-loader/commit/9f876d2))
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
<a name="0.28.9"></a>
|
|
53
|
-
## [0.28.9](https://github.com/webpack-contrib/css-loader/compare/v0.28.8...v0.28.9) (2018-01-17)
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
### Bug Fixes
|
|
57
|
-
|
|
58
|
-
* ignore invalid URLs (`url()`) ([#663](https://github.com/webpack-contrib/css-loader/issues/663)) ([d1d8221](https://github.com/webpack-contrib/css-loader/commit/d1d8221))
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
<a name="0.28.8"></a>
|
|
63
|
-
## [0.28.8](https://github.com/webpack-contrib/css-loader/compare/v0.28.7...v0.28.8) (2018-01-05)
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
### Bug Fixes
|
|
67
|
-
|
|
68
|
-
* **loader:** correctly check if source map is `undefined` ([#641](https://github.com/webpack-contrib/css-loader/issues/641)) ([0dccfa9](https://github.com/webpack-contrib/css-loader/commit/0dccfa9))
|
|
69
|
-
* proper URL escaping and wrapping (`url()`) ([#627](https://github.com/webpack-contrib/css-loader/issues/627)) ([8897d44](https://github.com/webpack-contrib/css-loader/commit/8897d44))
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
<a name="0.28.7"></a>
|
|
74
|
-
## [0.28.7](https://github.com/webpack/css-loader/compare/v0.28.6...v0.28.7) (2017-08-30)
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
### Bug Fixes
|
|
78
|
-
|
|
79
|
-
* pass resolver to `localsLoader` (`options.alias`) ([#601](https://github.com/webpack/css-loader/issues/601)) ([8f1b57c](https://github.com/webpack/css-loader/commit/8f1b57c))
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
<a name="0.28.6"></a>
|
|
84
|
-
## [0.28.6](https://github.com/webpack/css-loader/compare/v0.28.5...v0.28.6) (2017-08-30)
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
### Bug Fixes
|
|
88
|
-
|
|
89
|
-
* add support for aliases starting with `/` (`options.alias`) ([#597](https://github.com/webpack/css-loader/issues/597)) ([63567f2](https://github.com/webpack/css-loader/commit/63567f2))
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
<a name="0.28.5"></a>
|
|
94
|
-
## [0.28.5](https://github.com/webpack/css-loader/compare/v0.28.4...v0.28.5) (2017-08-17)
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
### Bug Fixes
|
|
98
|
-
|
|
99
|
-
* match mutliple dashes (`options.camelCase`) ([#556](https://github.com/webpack/css-loader/issues/556)) ([1fee601](https://github.com/webpack/css-loader/commit/1fee601))
|
|
100
|
-
* stricter `[@import](https://github.com/import)` tolerance ([#593](https://github.com/webpack/css-loader/issues/593)) ([2e4ec09](https://github.com/webpack/css-loader/commit/2e4ec09))
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
<a name="0.28.4"></a>
|
|
105
|
-
## [0.28.4](https://github.com/webpack/css-loader/compare/v0.28.3...v0.28.4) (2017-05-30)
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
### Bug Fixes
|
|
109
|
-
|
|
110
|
-
* preserve leading underscore in class names ([#543](https://github.com/webpack/css-loader/issues/543)) ([f6673c8](https://github.com/webpack/css-loader/commit/f6673c8))
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
<a name="0.28.3"></a>
|
|
115
|
-
## [0.28.3](https://github.com/webpack/css-loader/compare/v0.28.2...v0.28.3) (2017-05-25)
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
### Bug Fixes
|
|
119
|
-
|
|
120
|
-
* correct plugin order for CSS Modules ([#534](https://github.com/webpack/css-loader/issues/534)) ([b90f492](https://github.com/webpack/css-loader/commit/b90f492))
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
<a name="0.28.2"></a>
|
|
125
|
-
## [0.28.2](https://github.com/webpack/css-loader/compare/v0.28.1...v0.28.2) (2017-05-22)
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
### Bug Fixes
|
|
129
|
-
|
|
130
|
-
* source maps path on `windows` ([#532](https://github.com/webpack/css-loader/issues/532)) ([c3d0d91](https://github.com/webpack/css-loader/commit/c3d0d91))
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
<a name="0.28.1"></a>
|
|
135
|
-
## [0.28.1](https://github.com/webpack/css-loader/compare/v0.28.0...v0.28.1) (2017-05-02)
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
### Bug Fixes
|
|
139
|
-
|
|
140
|
-
* allow to specify a full hostname as a root URL ([#521](https://github.com/webpack/css-loader/issues/521)) ([06d27a1](https://github.com/webpack/css-loader/commit/06d27a1))
|
|
141
|
-
* case insensitivity of [@import](https://github.com/import) ([#514](https://github.com/webpack/css-loader/issues/514)) ([de4356b](https://github.com/webpack/css-loader/commit/de4356b))
|
|
142
|
-
* don't handle empty [@import](https://github.com/import) and url() ([#513](https://github.com/webpack/css-loader/issues/513)) ([868fc94](https://github.com/webpack/css-loader/commit/868fc94))
|
|
143
|
-
* imported variables are replaced in exports if followed by a comma ([#504](https://github.com/webpack/css-loader/issues/504)) ([956bad7](https://github.com/webpack/css-loader/commit/956bad7))
|
|
144
|
-
* loader now correctly handles `url` with space(s) ([#495](https://github.com/webpack/css-loader/issues/495)) ([534ea55](https://github.com/webpack/css-loader/commit/534ea55))
|
|
145
|
-
* url with a trailing space is now handled correctly ([#494](https://github.com/webpack/css-loader/issues/494)) ([e1ec4f2](https://github.com/webpack/css-loader/commit/e1ec4f2))
|
|
146
|
-
* use `btoa` instead `Buffer` ([#501](https://github.com/webpack/css-loader/issues/501)) ([fbb0714](https://github.com/webpack/css-loader/commit/fbb0714))
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
### Performance Improvements
|
|
150
|
-
|
|
151
|
-
* generate source maps only when explicitly set ([#478](https://github.com/webpack/css-loader/issues/478)) ([b8f5c8f](https://github.com/webpack/css-loader/commit/b8f5c8f))
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
<a name="0.28.0"></a>
|
|
156
|
-
# [0.28.0](https://github.com/webpack/css-loader/compare/v0.27.3...v0.28.0) (2017-03-30)
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
### Features
|
|
160
|
-
|
|
161
|
-
* add alias feature to rewrite URLs ([#274](https://github.com/webpack/css-loader/issues/274)) ([c8db489](https://github.com/webpack/css-loader/commit/c8db489))
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
<a name="0.27.3"></a>
|
|
166
|
-
## [0.27.3](https://github.com/webpack/css-loader/compare/v0.27.2...v0.27.3) (2017-03-13)
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
<a name="0.27.2"></a>
|
|
171
|
-
# [0.27.2](https://github.com/webpack/css-loader/compare/v0.27.1...v0.27.2) (2017-03-12)
|
|
172
|
-
|
|
173
|
-
<a name="0.27.1"></a>
|
|
174
|
-
# [0.27.1](https://github.com/webpack/css-loader/compare/v0.27.0...v0.27.1) (2017-03-10)
|
|
175
|
-
|
|
176
|
-
<a name="0.27.0"></a>
|
|
177
|
-
# [0.27.0](https://github.com/webpack/css-loader/compare/v0.26.2...v0.27.0) (2017-03-10)
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
### Bug Fixes
|
|
181
|
-
|
|
182
|
-
* **sourcemaps:** use abs paths & remove sourceRoot ([c769ac3](https://github.com/webpack/css-loader/commit/c769ac3))
|
|
183
|
-
* `minimizeOptions` should be `query.minimize`! ([16c0858](https://github.com/webpack/css-loader/commit/16c0858))
|
|
184
|
-
* do not export duplicate keys ([#420](https://github.com/webpack/css-loader/issues/420)) ([a2b85d7](https://github.com/webpack/css-loader/commit/a2b85d7))
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
### Features
|
|
188
|
-
|
|
189
|
-
* allow removal of original class name ([#445](https://github.com/webpack/css-loader/issues/445)) ([3f78361](https://github.com/webpack/css-loader/commit/3f78361))
|
|
190
|
-
* Include the sourceMappingURL & sourceURL when toString() ([6da7e90](https://github.com/webpack/css-loader/commit/6da7e90))
|
package/index.js
DELETED
package/lib/compile-exports.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
var camelCase = require("lodash/camelCase");
|
|
2
|
-
|
|
3
|
-
function dashesCamelCase(str) {
|
|
4
|
-
return str.replace(/-+(\w)/g, function(match, firstLetter) {
|
|
5
|
-
return firstLetter.toUpperCase();
|
|
6
|
-
});
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
module.exports = function compileExports(result, importItemMatcher, camelCaseKeys) {
|
|
10
|
-
if (!Object.keys(result.exports).length) {
|
|
11
|
-
return "";
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
var exportJs = Object.keys(result.exports).reduce(function(res, key) {
|
|
15
|
-
var valueAsString = JSON.stringify(result.exports[key]);
|
|
16
|
-
valueAsString = valueAsString.replace(result.importItemRegExpG, importItemMatcher);
|
|
17
|
-
function addEntry(k) {
|
|
18
|
-
res.push("\t" + JSON.stringify(k) + ": " + valueAsString);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
var targetKey;
|
|
22
|
-
switch(camelCaseKeys) {
|
|
23
|
-
case true:
|
|
24
|
-
addEntry(key);
|
|
25
|
-
targetKey = camelCase(key);
|
|
26
|
-
if (targetKey !== key) {
|
|
27
|
-
addEntry(targetKey);
|
|
28
|
-
}
|
|
29
|
-
break;
|
|
30
|
-
case 'dashes':
|
|
31
|
-
addEntry(key);
|
|
32
|
-
targetKey = dashesCamelCase(key);
|
|
33
|
-
if (targetKey !== key) {
|
|
34
|
-
addEntry(targetKey);
|
|
35
|
-
}
|
|
36
|
-
break;
|
|
37
|
-
case 'only':
|
|
38
|
-
addEntry(camelCase(key));
|
|
39
|
-
break;
|
|
40
|
-
case 'dashesOnly':
|
|
41
|
-
addEntry(dashesCamelCase(key));
|
|
42
|
-
break;
|
|
43
|
-
default:
|
|
44
|
-
addEntry(key);
|
|
45
|
-
break;
|
|
46
|
-
}
|
|
47
|
-
return res;
|
|
48
|
-
}, []).join(",\n");
|
|
49
|
-
|
|
50
|
-
return "{\n" + exportJs + "\n}";
|
|
51
|
-
};
|
package/lib/css-base.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
-
Author Tobias Koppers @sokra
|
|
4
|
-
*/
|
|
5
|
-
// css base code, injected by the css-loader
|
|
6
|
-
module.exports = function(useSourceMap) {
|
|
7
|
-
var list = [];
|
|
8
|
-
|
|
9
|
-
// return the list of modules as css string
|
|
10
|
-
list.toString = function toString() {
|
|
11
|
-
return this.map(function (item) {
|
|
12
|
-
var content = cssWithMappingToString(item, useSourceMap);
|
|
13
|
-
if(item[2]) {
|
|
14
|
-
return "@media " + item[2] + "{" + content + "}";
|
|
15
|
-
} else {
|
|
16
|
-
return content;
|
|
17
|
-
}
|
|
18
|
-
}).join("");
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
// import a list of modules into the list
|
|
22
|
-
list.i = function(modules, mediaQuery) {
|
|
23
|
-
if(typeof modules === "string")
|
|
24
|
-
modules = [[null, modules, ""]];
|
|
25
|
-
var alreadyImportedModules = {};
|
|
26
|
-
for(var i = 0; i < this.length; i++) {
|
|
27
|
-
var id = this[i][0];
|
|
28
|
-
if(typeof id === "number")
|
|
29
|
-
alreadyImportedModules[id] = true;
|
|
30
|
-
}
|
|
31
|
-
for(i = 0; i < modules.length; i++) {
|
|
32
|
-
var item = modules[i];
|
|
33
|
-
// skip already imported module
|
|
34
|
-
// this implementation is not 100% perfect for weird media query combinations
|
|
35
|
-
// when a module is imported multiple times with different media queries.
|
|
36
|
-
// I hope this will never occur (Hey this way we have smaller bundles)
|
|
37
|
-
if(typeof item[0] !== "number" || !alreadyImportedModules[item[0]]) {
|
|
38
|
-
if(mediaQuery && !item[2]) {
|
|
39
|
-
item[2] = mediaQuery;
|
|
40
|
-
} else if(mediaQuery) {
|
|
41
|
-
item[2] = "(" + item[2] + ") and (" + mediaQuery + ")";
|
|
42
|
-
}
|
|
43
|
-
list.push(item);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
return list;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
function cssWithMappingToString(item, useSourceMap) {
|
|
51
|
-
var content = item[1] || '';
|
|
52
|
-
var cssMapping = item[3];
|
|
53
|
-
if (!cssMapping) {
|
|
54
|
-
return content;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (useSourceMap && typeof btoa === 'function') {
|
|
58
|
-
var sourceMapping = toComment(cssMapping);
|
|
59
|
-
var sourceURLs = cssMapping.sources.map(function (source) {
|
|
60
|
-
return '/*# sourceURL=' + cssMapping.sourceRoot + source + ' */'
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
return [content].concat(sourceURLs).concat([sourceMapping]).join('\n');
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return [content].join('\n');
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// Adapted from convert-source-map (MIT)
|
|
70
|
-
function toComment(sourceMap) {
|
|
71
|
-
// eslint-disable-next-line no-undef
|
|
72
|
-
var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap))));
|
|
73
|
-
var data = 'sourceMappingURL=data:application/json;charset=utf-8;base64,' + base64;
|
|
74
|
-
|
|
75
|
-
return '/*# ' + data + ' */';
|
|
76
|
-
}
|
package/lib/getImportPrefix.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
-
Author Tobias Koppers @sokra
|
|
4
|
-
*/
|
|
5
|
-
module.exports = function getImportPrefix(loaderContext, query) {
|
|
6
|
-
if(query.importLoaders === false)
|
|
7
|
-
return "";
|
|
8
|
-
var importLoaders = parseInt(query.importLoaders, 10) || 0;
|
|
9
|
-
var loadersRequest = loaderContext.loaders.slice(
|
|
10
|
-
loaderContext.loaderIndex,
|
|
11
|
-
loaderContext.loaderIndex + 1 + importLoaders
|
|
12
|
-
).map(function(x) { return x.request; }).join("!");
|
|
13
|
-
return "-!" + loadersRequest + "!";
|
|
14
|
-
};
|
package/lib/getLocalIdent.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
-
Author Tobias Koppers @sokra
|
|
4
|
-
*/
|
|
5
|
-
var loaderUtils = require("loader-utils");
|
|
6
|
-
var path = require("path");
|
|
7
|
-
|
|
8
|
-
module.exports = function getLocalIdent(loaderContext, localIdentName, localName, options) {
|
|
9
|
-
if(!options.context) {
|
|
10
|
-
if (loaderContext.rootContext) {
|
|
11
|
-
options.context = loaderContext.rootContext;
|
|
12
|
-
} else if (loaderContext.options && typeof loaderContext.options.context === "string") {
|
|
13
|
-
options.context = loaderContext.options.context;
|
|
14
|
-
} else {
|
|
15
|
-
options.context = loaderContext.context;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
var request = path.relative(options.context, loaderContext.resourcePath);
|
|
19
|
-
options.content = options.hashPrefix + request + "+" + localName;
|
|
20
|
-
localIdentName = localIdentName.replace(/\[local\]/gi, localName);
|
|
21
|
-
var hash = loaderUtils.interpolateName(loaderContext, localIdentName, options);
|
|
22
|
-
return hash.replace(new RegExp("[^a-zA-Z0-9\\-_\u00A0-\uFFFF]", "g"), "-").replace(/^((-?[0-9])|--)/, "_$1");
|
|
23
|
-
};
|
package/lib/loader.js
DELETED
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
-
Author Tobias Koppers @sokra
|
|
4
|
-
*/
|
|
5
|
-
var loaderUtils = require("loader-utils");
|
|
6
|
-
var processCss = require("./processCss");
|
|
7
|
-
var getImportPrefix = require("./getImportPrefix");
|
|
8
|
-
var compileExports = require("./compile-exports");
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
module.exports = function(content, map) {
|
|
12
|
-
var callback = this.async();
|
|
13
|
-
var query = loaderUtils.getOptions(this) || {};
|
|
14
|
-
var moduleMode = query.modules;
|
|
15
|
-
var camelCaseKeys = query.camelCase;
|
|
16
|
-
var sourceMap = query.sourceMap || false;
|
|
17
|
-
|
|
18
|
-
if(sourceMap) {
|
|
19
|
-
if (map) {
|
|
20
|
-
if (typeof map === "string") {
|
|
21
|
-
map = JSON.stringify(map);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
if (map.sources) {
|
|
25
|
-
map.sources = map.sources.map(function (source) {
|
|
26
|
-
return source.replace(/\\/g, '/');
|
|
27
|
-
});
|
|
28
|
-
map.sourceRoot = '';
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
} else {
|
|
32
|
-
// Some loaders (example `"postcss-loader": "1.x.x"`) always generates source map, we should remove it
|
|
33
|
-
map = null;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
processCss(content, map, {
|
|
37
|
-
mode: moduleMode ? "local" : "global",
|
|
38
|
-
from: loaderUtils.getRemainingRequest(this).split("!").pop(),
|
|
39
|
-
to: loaderUtils.getCurrentRequest(this).split("!").pop(),
|
|
40
|
-
query: query,
|
|
41
|
-
loaderContext: this,
|
|
42
|
-
sourceMap: sourceMap
|
|
43
|
-
}, function(err, result) {
|
|
44
|
-
if(err) return callback(err);
|
|
45
|
-
|
|
46
|
-
var cssAsString = JSON.stringify(result.source);
|
|
47
|
-
|
|
48
|
-
// for importing CSS
|
|
49
|
-
var importUrlPrefix = getImportPrefix(this, query);
|
|
50
|
-
|
|
51
|
-
var alreadyImported = {};
|
|
52
|
-
var importJs = result.importItems.map(function(imp) {
|
|
53
|
-
// fixes #781 when importing `url(filename.css )`
|
|
54
|
-
imp.url = imp.url.trim();
|
|
55
|
-
return imp;
|
|
56
|
-
}).filter(function(imp) {
|
|
57
|
-
if(!imp.mediaQuery) {
|
|
58
|
-
if(alreadyImported[imp.url])
|
|
59
|
-
return false;
|
|
60
|
-
alreadyImported[imp.url] = true;
|
|
61
|
-
}
|
|
62
|
-
return true;
|
|
63
|
-
}).map(function(imp) {
|
|
64
|
-
if(!loaderUtils.isUrlRequest(imp.url)) {
|
|
65
|
-
return "exports.push([module.id, " +
|
|
66
|
-
JSON.stringify("@import url(" + imp.url + ");") + ", " +
|
|
67
|
-
JSON.stringify(imp.mediaQuery) + "]);";
|
|
68
|
-
} else {
|
|
69
|
-
var importUrl = importUrlPrefix + imp.url;
|
|
70
|
-
return "exports.i(require(" + loaderUtils.stringifyRequest(this, importUrl) + "), " + JSON.stringify(imp.mediaQuery) + ");";
|
|
71
|
-
}
|
|
72
|
-
}, this).join("\n");
|
|
73
|
-
|
|
74
|
-
function importItemMatcher(item) {
|
|
75
|
-
var match = result.importItemRegExp.exec(item);
|
|
76
|
-
var idx = +match[1];
|
|
77
|
-
var importItem = result.importItems[idx];
|
|
78
|
-
var importUrl = importUrlPrefix + importItem.url;
|
|
79
|
-
return "\" + require(" + loaderUtils.stringifyRequest(this, importUrl) + ").locals" +
|
|
80
|
-
"[" + JSON.stringify(importItem.export) + "] + \"";
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
cssAsString = cssAsString.replace(result.importItemRegExpG, importItemMatcher.bind(this));
|
|
84
|
-
|
|
85
|
-
// helper for ensuring valid CSS strings from requires
|
|
86
|
-
var urlEscapeHelper = "";
|
|
87
|
-
|
|
88
|
-
if(query.url !== false && result.urlItems.length > 0) {
|
|
89
|
-
urlEscapeHelper = "var escape = require(" + loaderUtils.stringifyRequest(this, require.resolve("./url/escape.js")) + ");\n";
|
|
90
|
-
|
|
91
|
-
cssAsString = cssAsString.replace(result.urlItemRegExpG, function(item) {
|
|
92
|
-
var match = result.urlItemRegExp.exec(item);
|
|
93
|
-
var idx = +match[1];
|
|
94
|
-
var urlItem = result.urlItems[idx];
|
|
95
|
-
var url = urlItem.url;
|
|
96
|
-
idx = url.indexOf("?#");
|
|
97
|
-
if(idx < 0) idx = url.indexOf("#");
|
|
98
|
-
var urlRequest;
|
|
99
|
-
if(idx > 0) { // idx === 0 is catched by isUrlRequest
|
|
100
|
-
// in cases like url('webfont.eot?#iefix')
|
|
101
|
-
urlRequest = url.substr(0, idx);
|
|
102
|
-
return "\" + escape(require(" + loaderUtils.stringifyRequest(this, urlRequest) + ")) + \"" +
|
|
103
|
-
url.substr(idx);
|
|
104
|
-
}
|
|
105
|
-
urlRequest = url;
|
|
106
|
-
return "\" + escape(require(" + loaderUtils.stringifyRequest(this, urlRequest) + ")) + \"";
|
|
107
|
-
}.bind(this));
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
var exportJs = compileExports(result, importItemMatcher.bind(this), camelCaseKeys);
|
|
111
|
-
if (exportJs) {
|
|
112
|
-
exportJs = "exports.locals = " + exportJs + ";";
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
var moduleJs;
|
|
116
|
-
if(sourceMap && result.map) {
|
|
117
|
-
// add a SourceMap
|
|
118
|
-
map = result.map;
|
|
119
|
-
if(map.sources) {
|
|
120
|
-
map.sources = map.sources.map(function(source) {
|
|
121
|
-
return source.split("!").pop().replace(/\\/g, '/');
|
|
122
|
-
}, this);
|
|
123
|
-
map.sourceRoot = "";
|
|
124
|
-
}
|
|
125
|
-
map.file = map.file.split("!").pop().replace(/\\/g, '/');
|
|
126
|
-
map = JSON.stringify(map);
|
|
127
|
-
moduleJs = "exports.push([module.id, " + cssAsString + ", \"\", " + map + "]);";
|
|
128
|
-
} else {
|
|
129
|
-
moduleJs = "exports.push([module.id, " + cssAsString + ", \"\"]);";
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
// embed runtime
|
|
133
|
-
callback(null, urlEscapeHelper +
|
|
134
|
-
"exports = module.exports = require(" +
|
|
135
|
-
loaderUtils.stringifyRequest(this, require.resolve("./css-base.js")) +
|
|
136
|
-
")(" + sourceMap + ");\n" +
|
|
137
|
-
"// imports\n" +
|
|
138
|
-
importJs + "\n\n" +
|
|
139
|
-
"// module\n" +
|
|
140
|
-
moduleJs + "\n\n" +
|
|
141
|
-
"// exports\n" +
|
|
142
|
-
exportJs);
|
|
143
|
-
}.bind(this));
|
|
144
|
-
};
|