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:

How to start with an empty app

+

To start with a fresh app with no boilerplate, run jss create nextjs --empty. 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:

    -
  1. Delete /src/components/Styleguide* and /src/components/GraphQL*
  2. -
  3. Delete graphql-let command from bootstrap npm command in package.json until you create .graphql files
  4. -
  5. Delete /sitecore/definitions/components/Styleguide*, /sitecore/definitions/templates/Styleguide*, and /sitecore/definitions/components/GraphQL*
  6. -
  7. Delete /data/component-content/Styleguide
  8. -
  9. Delete /data/content/Styleguide
  10. -
  11. Delete /data/routes/styleguide and /data/routes/graphql
  12. Delete /data/dictionary/*.yml
  13. +
  14. Delete /data/routes/styleguide and /data/routes/graphql
  15. +
  16. Delete /data/content/Styleguide
  17. +
  18. Delete /data/component-content/Styleguide
  19. +
  20. Delete /sitecore/definitions/components/Styleguide*, /sitecore/definitions/templates/Styleguide*, and /sitecore/definitions/components/GraphQL*
  21. +
  22. Delete graphql-let command from bootstrap npm command in package.json until you create .graphql files
  23. +
  24. Delete /src/components/*
diff --git a/samples/nextjs/src/Layout.tsx b/samples/nextjs/src/Layout.tsx index 31ace51778..97eb4db777 100644 --- a/samples/nextjs/src/Layout.tsx +++ b/samples/nextjs/src/Layout.tsx @@ -34,15 +34,17 @@ const Navigation = () => { href="https://jss.sitecore.com" target="_blank" rel="noopener noreferrer" - > + > {t('Documentation')} + {/* #START_EMPTY */} {t('Styleguide')} {t('GraphQL')} + {/* #END_EMPTY */} ); @@ -80,7 +82,6 @@ const Layout = ({ context }: LayoutProps): JSX.Element => { - {/* root placeholder for the app, which we add components to using route data */}