Development Setup
Complete guide for setting up a local development environment for the Cold Steel BigCommerce theme.
Prerequisites
Required Software
Node.js & npm
- Version: Node.js 14.x or higher
- npm: 6.x or higher
- Download: https://nodejs.org/
Verify installation:
node --version # Should show v14.x.x or higher
npm --version # Should show 6.x.x or higher
BigCommerce Stencil CLI
npm install -g @bigcommerce/[email protected]
Verify installation:
stencil --version # Should show 8.10.5
Git
- Download: https://git-scm.com/
- Required for version control and repository access
BigCommerce Store Requirements
-
Store Access
- Admin account with Developer or Store Owner permissions
- Store must be on a plan that supports Stencil (Standard or higher)
-
API Credentials
- Store API account with Themes scope
- Available in: Advanced Settings → API Accounts
Repository Setup
Clone Repository
# Navigate to your projects directory
cd Z:\Repos
# Clone the repository
git clone [repository-url] coldsteel.com
# Navigate into directory
cd coldsteel.com
Install Dependencies
# Install all npm packages
npm install
This will install:
- BigCommerce Stencil CLI
- Webpack and build tools
- JavaScript dependencies (jQuery, Foundation, Swiper, etc.)
- Development dependencies (Babel, ESLint, Grunt)
Expected time: 2-5 minutes depending on internet speed.
Stencil Configuration
Initialize Stencil
stencil init
You'll be prompted for:
-
Store URL:
https://your-store.mybigcommerce.com- Your BigCommerce store URL
- Can be sandbox or production
-
Access Token: Your API access token
- From Advanced Settings → API Accounts
- Should have Themes scope
-
Port: Default
3000- Port for local development server
- Press Enter to use default
This creates .stencil file with your store credentials.
Configuration Files
After initialization, you should have:
coldsteel.com/
├── .stencil # API credentials (DO NOT COMMIT)
├── secrets.stencil.json # Secret configuration (DO NOT COMMIT)
├── config.stencil.json # Theme settings
└── stencil.conf.js # Build configuration
Secrets Configuration
If using custom API endpoints (like engraving API), create secrets.stencil.json:
{
"engraving_api_key": "your-api-key-here",
"engraving_api_url": "https://engraving-test.gsmoutdoors.com"
}
Important: Never commit .stencil or secrets.stencil.json to version control!
Local Development
Start Development Server
stencil start
This will:
- Compile assets with Webpack (development mode)
- Start local server at http://localhost:3000
- Enable hot reloading for template changes
- Watch for file changes
Output:
Compiled with warnings in 5432 ms
✔ Development Server Started
URL: http://localhost:3000
Store: https://your-store.mybigcommerce.com
SSL: Enabled
Access Local Site
Open http://localhost:3000 in your browser.
Features:
- Live reload on template changes
- HTTPS with self-signed certificate (you'll see a security warning - this is normal)
- Connected to your BigCommerce store's data
- Full e-commerce functionality
Development Workflow
1. Template Development
Edit Handlebars templates:
templates/
├── pages/product.html
├── components/elevate/header.html
└── ...
Changes are detected automatically and trigger reload.
2. JavaScript Development
Edit JS modules:
assets/js/
├── app.js
├── theme/
│ ├── product.js
│ └── ...
└── ...
Webpack watches for changes and recompiles automatically.
3. Style Development
Edit SCSS files:
assets/scss/
├── theme.scss
├── components/
└── ...
SCSS compiles to CSS automatically on save.
Hot Reloading
Automatic Reload For:
- Template changes (
.htmlfiles) - JavaScript changes (
.jsfiles) - Style changes (
.scssfiles)
Requires Manual Refresh:
- Configuration changes (
config.json) - Schema changes (
schema.json) - Language changes (
lang/files)
Building Assets
Development Build
npm run buildDev
Creates development bundles:
- Non-minified code
- Source maps included
- Faster compilation
Output: assets/dist/
Production Build
npm run build
Creates optimized production bundles:
- Minified JavaScript
- Optimized CSS
- Removed console logs
- Tree-shaking applied
Bundle Analysis
To analyze bundle sizes:
npm run build
Opens report.html showing:
- Bundle composition
- Size of each module
- Dependency tree
- Opportunities for optimization
Testing
JavaScript Tests
npm test
Runs Jest test suite (if configured).
Linting
JavaScript Linting
npx grunt eslint
Checks JavaScript files against ESLint rules.
SCSS Linting
npx grunt scsslint
Checks SCSS files for style violations.
Run All Checks
npx grunt
Runs: ESLint, Jest, SCSS Lint, SVG Store
Git Workflow
Branch Strategy
# Create feature branch
git checkout -b feature/engraving-updates
# Make changes and commit
git add .
git commit -m "Add engraving font options"
# Push to remote
git push origin feature/engraving-updates
Before Committing
-
Lint your code
npx grunt eslint
npx grunt scsslint -
Build assets
npm run build -
Test on local store
stencil start
# Manually test changes
Deploying Changes
Bundle Theme
stencil bundle
Creates Cold Steel - [version].zip ready for upload.
Push to Store
stencil push
Uploads theme to BigCommerce:
- Prompts for theme name
- Asks if it should be applied immediately
- Uploads ZIP file
- Theme becomes available in BigCommerce admin
Options:
# Push without applying
stencil push
# Push and apply immediately
stencil push --activate
# Push to specific store
stencil push --store your-store-hash
Upload via Admin
Alternatively, upload manually:
- Run
stencil bundle - Go to Storefront → Themes in BigCommerce admin
- Click Upload Theme
- Select ZIP file
- Click Apply when ready
Debugging
Enable Console Logging
Development mode includes console logging:
// Automatically enabled in development
if (isDevelopment()) {
console.log('Debug information');
}
Handlebars Debugging
View page context:
Or specific variables:
Stencil CLI Debug Mode
stencil start --verbose
Shows detailed logging:
- File changes detected
- Compilation times
- API requests
- Error stack traces
Browser DevTools
Use browser DevTools to inspect:
- Network requests
- Console errors
- Element styles
- JavaScript execution
BigCommerce Logs
Check store logs:
- Settings → Store Logs
- Shows API errors, theme errors, webhook failures
Environment Variables
.env File (Optional)
Create .env for local overrides:
STENCIL_CLI_PORT=3000
NODE_ENV=development
ENGRAVING_API_URL=https://engraving-test.gsmoutdoors.com
Environment Detection
Code can detect environment:
const isDevelopment = () => {
return window.location.hostname.includes('localhost') ||
window.location.hostname.includes('loca.lt') ||
window.location.hostname.includes('-sandbox.mybigcommerce.com');
};
Common Issues
Port Already in Use
Error: EADDRINUSE: address already in use :::3000
Solution:
# Use different port
stencil start --port 3001
SSL Certificate Warning
Error: "Your connection is not private"
Solution: This is normal for local development. Click "Advanced" → "Proceed to localhost".
Module Not Found
Error: Cannot find module 'lodash'
Solution:
# Delete node_modules and reinstall
rm -rf node_modules
npm install
Stencil CLI Won't Start
Solution:
# Reinstall Stencil CLI globally
npm uninstall -g @bigcommerce/stencil-cli
npm install -g @bigcommerce/[email protected]
# Re-initialize
stencil init
Webpack Compilation Errors
Solution:
# Clear webpack cache
rm -rf assets/dist
npm run buildDev
API Authentication Errors
Solution:
- Verify API account in BigCommerce admin
- Check token has Themes scope
- Re-run
stencil initwith correct credentials
IDE Setup
Recommended: Visual Studio Code
Install extensions:
- Handlebars by Tobermory
- ESLint by Microsoft
- SCSS IntelliSense by mrmlnc
- GitLens by GitKraken
- Prettier by Prettier
VS Code Settings
.vscode/settings.json:
{
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"files.associations": {
"*.html": "handlebars"
},
"scss.lint.unknownAtRules": "ignore"
}
EditorConfig
.editorconfig (if not present, create):
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 4
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
[*.{json,yml}]
indent_size = 2
[*.md]
trim_trailing_whitespace = false
Documentation Resources
- BigCommerce Stencil Docs: https://developer.bigcommerce.com/stencil-docs
- Stencil CLI GitHub: https://github.com/bigcommerce/stencil-cli
- Theme Support: [email protected]
- BigCommerce DevCenter: https://developer.bigcommerce.com/
Next Steps
After setup:
- Review Architecture documentation
- Understand Theme Customizations
- Explore Engraving Tool implementation
- Study Build Process
- Review Integrations