@cypress/webpack-dev-server 3.1.2 → 3.2.1

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.
@@ -7,6 +7,8 @@ const os_1 = require("os");
7
7
  const path = tslib_1.__importStar(require("path"));
8
8
  const dynamic_import_1 = require("../dynamic-import");
9
9
  const sourceRelativeWebpackModules_1 = require("./sourceRelativeWebpackModules");
10
+ const debug_1 = tslib_1.__importDefault(require("debug"));
11
+ const debug = (0, debug_1.default)('cypress:webpack-dev-server:angularHandler');
10
12
  async function getProjectConfig(projectRoot) {
11
13
  var _a;
12
14
  const angularJson = await getAngularJson(projectRoot);
@@ -139,7 +141,30 @@ async function getAngularCliWebpackConfig(devServerConfig) {
139
141
  const tsConfig = await generateTsConfig(devServerConfig, projectConfig.buildOptions);
140
142
  const buildOptions = getAngularBuildOptions(projectConfig.buildOptions, tsConfig);
141
143
  const context = createFakeContext(projectRoot, projectConfig);
142
- const { config } = await generateBrowserWebpackConfigFromContext(buildOptions, context, (wco) => [getCommonConfig(wco), getStylesConfig(wco)]);
144
+ const { config } = await generateBrowserWebpackConfigFromContext(buildOptions, context, (wco) => {
145
+ const stylesConfig = getStylesConfig(wco);
146
+ // We modify resolve-url-loader and set `root` to be `projectRoot` + `sourceRoot` to ensure
147
+ // imports in scss, sass, etc are correctly resolved.
148
+ // https://github.com/cypress-io/cypress/issues/24272
149
+ stylesConfig.module.rules.forEach((rule) => {
150
+ var _a;
151
+ (_a = rule.rules) === null || _a === void 0 ? void 0 : _a.forEach((ruleSet) => {
152
+ if (!Array.isArray(ruleSet.use)) {
153
+ return;
154
+ }
155
+ ruleSet.use.map((loader) => {
156
+ var _a;
157
+ if (typeof loader !== 'object' || typeof loader.options !== 'object' || !((_a = loader.loader) === null || _a === void 0 ? void 0 : _a.includes('resolve-url-loader'))) {
158
+ return;
159
+ }
160
+ const root = path.join(devServerConfig.cypressConfig.projectRoot, projectConfig.sourceRoot);
161
+ debug('Adding root %s to resolve-url-loader options', root);
162
+ loader.options.root = path.join(devServerConfig.cypressConfig.projectRoot, projectConfig.sourceRoot);
163
+ });
164
+ });
165
+ });
166
+ return [getCommonConfig(wco), stylesConfig];
167
+ });
143
168
  delete config.entry.main;
144
169
  return config;
145
170
  }
package/dist/loader.js CHANGED
@@ -16,7 +16,7 @@ const makeImport = (file, filename, chunkName, projectRoot) => {
16
16
  // If we want to rename the chunks, we can use this
17
17
  const magicComments = chunkName ? `/* webpackChunkName: "${chunkName}" */` : '';
18
18
  return `"${filename}": {
19
- shouldLoad: () => document.location.pathname.includes("${encodeURI(file.absolute)}"),
19
+ shouldLoad: () => decodeURI(document.location.pathname).includes("${file.absolute}"),
20
20
  load: () => import("${file.absolute}" ${magicComments}),
21
21
  absolute: "${file.absolute.split(path.sep).join(path.posix.sep)}",
22
22
  relative: "${file.relative.split(path.sep).join(path.posix.sep)}",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cypress/webpack-dev-server",
3
- "version": "3.1.2",
3
+ "version": "3.2.1",
4
4
  "description": "Launches Webpack Dev Server for Component Testing",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {