I'm setting up a web project that can (i) interact with the Stacks blockchain and (ii) deploy/interact with Clarity smart contracts.
I need help in configuring the environment correctly. Following is how I typically setup web projects.
I typically use python's Django framework. Moreover, I create a Javascript pipeline as a standalone, separate environment inside the Django project.
I do that via initializing a new npm
project in the root of the Django project, and thereafter installing a bundler like webpack. I.e.:
npm init -y
npm install webpack webpack-cli --save-dev
This creates the package.json
and package-lock.json
files, as well as a node_modules
folder where JavaScript library dependencies reside.
Next, I create a webpack.config.js
file at the root of the Django project. I add an npm script target in package.json
to run webpack
. I can then run npm run dev
to execute the webpack script. This essentially sets up my Javascript pipeline, giving me a bundle
file I can use with Django's templates.
That's it.
In short, if I want to use any external JS library, I can simply install it via npm
, regenerate the webpack bundle
file via npm run dev
, and use the bundle in my Django templates.
This approach is quite flexible - I can even set up React
(with the Babel
compiler) within the Django project if need be.
My goal is to start testing Clarity code within this sort of a set up. I've already seen the basic documentation regarding testing Clarity code here: https://docs.stacks.co/docs/write-smart-contracts/
But that does not help one understand how to use Clarity code within a production-grade setup (of the sort I described above).
If you have experience regarding setting this up, please provide an illustrative example. Thanks in advance.