Skip to content

Can create a project with webpack bundled typescript support#111

Open
a-musing-moose wants to merge 1 commit intomainfrom
variant/webpack
Open

Can create a project with webpack bundled typescript support#111
a-musing-moose wants to merge 1 commit intomainfrom
variant/webpack

Conversation

@a-musing-moose
Copy link
Copy Markdown
Contributor

Adds optional static assets build pipeline using webpack as a bundler. Linting and formatting is provided by Prettier and the Ackama ESLint configuration.

If Typescript support is requests, the optional use of HTMX can also be turned on which will include htmx in the standard asset bundle as well as django-htmx for backend support.

@a-musing-moose a-musing-moose changed the title Can create a project with vite bundled typescript support Can create a project with webpack bundled typescript support Apr 28, 2026
Copy link
Copy Markdown
Contributor

@nzlaura nzlaura left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall I think this is looking good- a few comments on the prettier set up + npm run commands to start 😄

Comment thread template/{% if ts_integration %}package.json{% endif %}.jinja
Comment thread template/{% if ts_integration %}package.json{% endif %}.jinja Outdated
Comment thread template/{% if ts_integration %}package.json{% endif %}.jinja
Copy link
Copy Markdown

@G-Rath G-Rath left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks like a good start, but we're missing

  • the ESLint config (which'll reveal some other missing config and dependency stuff)
  • running type checking across the codebase
    • it's not sufficient to do type checking through ts-loader because that only checks files it imports

Comment thread template/{% if ts_integration %}package.json{% endif %}.jinja Outdated
Comment thread template/Dockerfile.jinja Outdated
Comment thread template/{% if ts_integration %}package.json{% endif %}.jinja Outdated
"eslint-plugin-n": "^17.24.0",
"eslint-plugin-prettier": "^5.5.5",
"prettier": "^3.8.3",
"ts-loader": "^9.5.4",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note/suggestion: I'm guessing you're relying on ts-loader to execute the actual type checking

I don't think that's the end of the world, but I would suggest in the long-run splitting them out because it means you don't have to spend time typechecking when building e.g. for deployments, and it makes it easier to iterate because you can still use the app even if your types are not perfect

generally we use Babel for compiling instead

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is now a npm run typecheck which should cover everything.

My understanding is that babel is faster because it strips types whereas ts-loader uses TSC and will therefore fail if there are typing errors. Otherwise they do pretty much the same thing. I'm more concerned about correct code than compilation times here as the amount of TS is tiny. But happy to conform with other project if you consider it important.

Comment thread template/{% if ts_integration %}tsconfig.json{% endif %}.jinja Outdated
Comment thread template/{% if ts_integration %}webpack.config.js{% endif %}.jinja Outdated
@a-musing-moose a-musing-moose force-pushed the variant/webpack branch 8 times, most recently from 7b5a3e3 to 5e17602 Compare April 29, 2026 05:46
Comment thread template/Dockerfile.jinja Outdated
Comment on lines +6 to +11
COPY webpack.config.js tsconfig.json package.json package-lock.json /source/
WORKDIR /source
RUN npm cli

COPY src/assets /source/src/assets/
RUN npm run build
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: the command is npm ci, and the webpack config has been renamed to .ts

also you can copy the configs after installing

Suggested change
COPY webpack.config.js tsconfig.json package.json package-lock.json /source/
WORKDIR /source
RUN npm cli
COPY src/assets /source/src/assets/
RUN npm run build
COPY package.json package-lock.json /source/
WORKDIR /source
RUN npm ci
COPY webpack.config.ts tsconfig.json /source
COPY src/assets /source/src/assets/
RUN npm run build

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks - is the delayed copy to make better use of docker layer caching or is there another reason?

Comment on lines +11 to +14
'.venv/*',
'htmlcov/*',
'node_modules/*',
'src/{{ project_module }}/static/assets/*'
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: node_modules is already ignored by our shared config

Also happy to add .venv to that list (we could also add htmlcov, though conventionally all our other tools use coverage which is already ignored, so might be worth discussing going the other way on that)

Suggested change
'.venv/*',
'htmlcov/*',
'node_modules/*',
'src/{{ project_module }}/static/assets/*'
'.venv/*',
'htmlcov/*',
'src/{{ project_module }}/static/assets/*'

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've removed node_modules but left the others in. Should you add .venv and htmlcov to the shared config I'll remove.

htmlcov in particular is the folder in which the human readable coverage report is generated. This is the default for the Python coverage tool.

It keeps the actual coverage data in a binary .coverage file. We also product a coverage.xml for CI integration which always seems to want Cobertura XML files.

Comment thread template/{% if ts_integration %}eslint.config.js{% endif %}.jinja
Comment thread template/{% if ts_integration %}webpack.config.ts{% endif %}.jinja Outdated
Comment thread template/{% if ts_integration %}webpack.config.ts{% endif %}.jinja
@a-musing-moose a-musing-moose force-pushed the variant/webpack branch 2 times, most recently from 6f20875 to 050946e Compare April 29, 2026 23:09
@a-musing-moose a-musing-moose requested a review from G-Rath April 29, 2026 23:09
@a-musing-moose a-musing-moose force-pushed the variant/webpack branch 4 times, most recently from 18389dd to b839815 Compare April 30, 2026 00:49
Adds optional static assets build pipeline using webpack as a bundler.
Linting and formatting is provided by Prettier and the Ackama ESLint
configuration.

If Typescript support is requests, the optional use of HTMX can also be
turned on which will include htmx in the standard asset bundle as well
as django-htmx for backend support.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants