diff --git a/packages/react-scripts/config/webpack.config.js b/packages/react-scripts/config/webpack.config.js index ec7f3b3dffe..96a38a3c6c1 100644 --- a/packages/react-scripts/config/webpack.config.js +++ b/packages/react-scripts/config/webpack.config.js @@ -133,6 +133,7 @@ module.exports = function (webpackEnv) { loader: require.resolve('resolve-url-loader'), options: { sourceMap: isEnvProduction ? shouldUseSourceMap : isEnvDevelopment, + root: paths.appSrc, }, }, { diff --git a/test/fixtures/global-scss-asset-resolution/.disable-pnp b/test/fixtures/global-scss-asset-resolution/.disable-pnp new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/fixtures/global-scss-asset-resolution/index.test.js b/test/fixtures/global-scss-asset-resolution/index.test.js new file mode 100644 index 00000000000..4be53d03460 --- /dev/null +++ b/test/fixtures/global-scss-asset-resolution/index.test.js @@ -0,0 +1,16 @@ +const testSetup = require('../__shared__/test-setup'); + +if (testSetup.isLocal) { + // TODO: make this work locally + test('skipped locally', () => {}); +} else { + test('builds in development', async () => { + const { fulfilled } = await testSetup.scripts.start({ smoke: true }); + expect(fulfilled).toBe(true); + }); + + test('builds in production', async () => { + const { fulfilled } = await testSetup.scripts.build(); + expect(fulfilled).toBe(true); + }); +} diff --git a/test/fixtures/global-scss-asset-resolution/package.json b/test/fixtures/global-scss-asset-resolution/package.json new file mode 100644 index 00000000000..aadc890ec0a --- /dev/null +++ b/test/fixtures/global-scss-asset-resolution/package.json @@ -0,0 +1,7 @@ +{ + "dependencies": { + "node-sass": "4.x", + "react": "latest", + "react-dom": "latest" + } +} diff --git a/test/fixtures/global-scss-asset-resolution/src/images/logo.svg b/test/fixtures/global-scss-asset-resolution/src/images/logo.svg new file mode 100644 index 00000000000..6b60c1042f5 --- /dev/null +++ b/test/fixtures/global-scss-asset-resolution/src/images/logo.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/test/fixtures/global-scss-asset-resolution/src/index.js b/test/fixtures/global-scss-asset-resolution/src/index.js new file mode 100644 index 00000000000..9fc16c21ff9 --- /dev/null +++ b/test/fixtures/global-scss-asset-resolution/src/index.js @@ -0,0 +1,5 @@ +import React from 'react'; +import ReactDOM from 'react-dom'; +import './index.scss'; + +ReactDOM.render(
, document.getElementById('root')); diff --git a/test/fixtures/global-scss-asset-resolution/src/index.scss b/test/fixtures/global-scss-asset-resolution/src/index.scss new file mode 100644 index 00000000000..151c0b4a6cd --- /dev/null +++ b/test/fixtures/global-scss-asset-resolution/src/index.scss @@ -0,0 +1,5 @@ +#root { + width: 300px; + height: 300px; + background: url(/images/logo.svg) center/cover no-repeat; +}