diff --git a/packages/sitecore-jss-dev-tools/src/templating/strip.test.ts b/packages/sitecore-jss-dev-tools/src/templating/strip.test.ts index 60730f8b51..a8bcc6b4bf 100644 --- a/packages/sitecore-jss-dev-tools/src/templating/strip.test.ts +++ b/packages/sitecore-jss-dev-tools/src/templating/strip.test.ts @@ -137,6 +137,10 @@ describe('strip', () => { 'testdir2/test23.js', 'Test81\r\n// #START_STRIP\r\nTest82 Test83\r\n// #END_STRIP\r\nTest84\r\nTest85' ); + stubFileContent( + 'testjsx.ts', + 'return (\r\n<>\r\n{/* #START_STRIP */}\r\nTest86\r\nTest87\r\n{/* #END_STRIP */}\r\nTest88\r\nTest89\r\n>\r\n)' + ); globStub.returns([ 'test1.ts', @@ -148,13 +152,14 @@ describe('strip', () => { 'testdir2/test21.ts', 'testdir2/test22.tsx', 'testdir2/test23.js', + 'testjsx.ts', ]); const settings = { stripCode: true }; strip.strip(settings); - expect(writeFileSyncStub.callCount).to.equal(9); + expect(writeFileSyncStub.callCount).to.equal(10); const testCompile = (callIndex: number, filePath: string, content: string) => { expect(writeFileSyncStub.getCall(callIndex).args).to.deep.equal([ @@ -172,6 +177,7 @@ describe('strip', () => { testCompile(6, 'testdir2/test21.ts', 'Test61\r\nTest64\r\nTest65'); testCompile(7, 'testdir2/test22.tsx', 'Test71\r\nTest74\r\nTest75'); testCompile(8, 'testdir2/test23.js', 'Test81\r\nTest84\r\nTest85'); + testCompile(9, 'testjsx.ts', 'return (\r\n<>\r\nTest88\r\nTest89\r\n>\r\n)'); globStub.restore(); writeFileSyncStub.restore(); diff --git a/packages/sitecore-jss-dev-tools/src/templating/strip.ts b/packages/sitecore-jss-dev-tools/src/templating/strip.ts index d429e36c8e..735c2ebb17 100644 --- a/packages/sitecore-jss-dev-tools/src/templating/strip.ts +++ b/packages/sitecore-jss-dev-tools/src/templating/strip.ts @@ -12,7 +12,9 @@ const IGNORE_PATTERN = '@(node_modules|dist|.next|out|.generated)/**'; * @returns {RegExp} regExp */ const getStripRegExp = (prefix: string, suffix = 'STRIP') => { - return new RegExp(`// #${prefix}_${suffix}`, 'g'); + const name = `#${prefix}_${suffix}`; + + return new RegExp(`(// ${name})|({\\/\\* ${name} \\*\\/})`, 'g'); }; interface StripSettings { @@ -79,7 +81,7 @@ export const compile = (file: string, settings: StripSettings) => { /** * Removes part of code which inside the special comments block. - * Compiles each not excluded file starting from current dirrectory (or `settings.sourcePath`). + * Compiles each not excluded file starting from current directory (or `settings.sourcePath`). * @param {StripSettings} settings */ export const strip = (settings: StripSettings = {}) => { diff --git a/samples/nextjs/data/routes/en.yml b/samples/nextjs/data/routes/en.yml index e2b8451242..4b6f145f14 100644 --- a/samples/nextjs/data/routes/en.yml +++ b/samples/nextjs/data/routes/en.yml @@ -49,14 +49,15 @@ placeholders:
To start with a fresh app with no boilerplate, run jss create
. Note, disconnected mode is not supported this way
To remove all of the default sample content (the Styleguide and GraphQL routes) and start out with an empty JSS app:
/src/components/Styleguide*
and /src/components/GraphQL*
graphql-let
command from bootstrap
npm command in package.json
until you create .graphql
files/sitecore/definitions/components/Styleguide*
, /sitecore/definitions/templates/Styleguide*
, and /sitecore/definitions/components/GraphQL*
/data/component-content/Styleguide
/data/content/Styleguide
/data/routes/styleguide
and /data/routes/graphql
/data/dictionary/*.yml
/data/routes/styleguide
and /data/routes/graphql
/data/content/Styleguide
/data/component-content/Styleguide
/sitecore/definitions/components/Styleguide*
, /sitecore/definitions/templates/Styleguide*
, and /sitecore/definitions/components/GraphQL*
graphql-let
command from bootstrap
npm command in package.json
until you create .graphql
files/src/components/*