Minimal Webpack 4 boilerplate for template development for Shopnex. has Babel, Sass, ESLint, Hot Module Replacement, and optimized for development/production.
git clone https://github.com/rahul-soni11/webpack-boilerplate-django.git
npm i
For testing templates locally you need to have a running copy of the Django project.
- Set
public_path: 'http://localhost:8080/'
in config/paths.js file. So your template can load assets from the localhost. - Start local server
npm start
, This will generate dist/webpack-stats.json file. Login to superadmin site of your tenant and copy data from webpack-stats.json file to Site Settings > Webpack stats: and Save.
By default, the Shopnex project will look for the templates in an S3 bucket named as tenant's hostname/template/.
Follow given steps to add the path of template folder in template settings, so if the template not found in the S3 bucket it will load from the specified location.
Note: Make sure there are no templates files in available in S3 bucket named as your tenant's hostname
- After cloning this repo, Copy the absolute path of
/src/html/
dir. example:
cd sevenpillarsdesign-webpack/src/html
run pwd
, this will give you full path like /Users/rahulsoni/React/sevenpillarsdesign-webpack/src/html
- Edit
TEMPLATES
settings in the Django project. Add path in theDIRS
list.
for shopnex e-commerce project you need to edit ecommerce/settings/base.py file.
TEMPLATES = [{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
os.path.join(BASE_DIR, '../templates/'),
'PASTE_FULL_PATH_OF_HTML_WHAT_WE_COPIED_IN_STEP_1',
],
'OPTIONS': {
'context_processors': context_processors,
'loaders': loaders,
},
}]
To deploy bundle you need to build and sync dist folder with S3 bucket. S3BUCKETNAME = named as tenants hostname
- Set
public_path: 'https://s3.ap-south-1.amazonaws.com/<_S3BUCKETNAME_>/'
- build the project.
npm run build
- cd into dist dir and sync with s3
aws s3 sync . s3://<_YOUR_BUCKET_NAME_>
-
Make static directory public in S3 bucket.
-
Login to superadmin site of your tenant and copy data from dist/webpack-stats.json file to Site Settings > Webpack stats: and Save.
webpack
- Module and asset bundler.webpack-cli
- Command line interface for Webpack.webpack-dev-server
- Development server for Webpack.webpack-merge
- Simplify development/production configurationcross-env
- Cross platform configuration.
@babel/core
- Transpile ES6+ to backwards compatible JavaScript.@babel/plugin-proposal-class-properties
- Use properties directly on a class.@babel/preset-env
- Smart defaults for Babel.babel-eslint
- Lint Babel code.eslint
- ESLint.
babel-loader
- Transpile files with Babel and Webpack.sass-loader
- Load SCSS and compile to CSS.node-sass
- Node Sass.
postcss-loader
- Process CSS with PostCSS.cssnano
- Optimize and compress PostCSS.postcss-preset-env
- Sensible defaults for PostCSS.
css-loader
- Resolves CSS imports into JS.style-loader
- Inject CSS into the DOM.eslint-loader
- Use ESLint with Webpack.file-loader
- Copy files to build folder.url-loader
- Encode and inline files. Falls back to file-loader.
clean-webpack-plugin
- Remove/clean build folders.copy-webpack-plugin
- Copy files to build directory.html-webpack-plugin
- Generate HTML files from template.mini-css-extract-plugin
- Extract CSS into separate files.optimize-css-assets-webpack-plugin
- Optimize and minimize CSS assets.terser-webpack-plugin
- Minify JavaScript.
File structure reference for Django Shopnex ecommerce project.
html/ โโโ accounts โย ย โโโ auth โย ย โโโ _form_errors.html โย ย โโโ account_activation_blank.html โย ย โโโ login.html โย ย โโโ register.html โย ย โโโ send_confirm_email.html โโโ base.html โโโ blank-page.html โโโ cart.html โโโ flatpages โย ย โโโ default.html โโโ footer.html โโโ navbar โย ย โโโ _auth_cart.html โย ย โโโ navbar.html โโโ products โย ย โโโ _items.html โย ย โโโ detail-parts โย ย โย ย โโโ _description.html โย ย โย ย โโโ _images.html โย ย โโโ detail.html โย ย โโโ list.html โย ย โโโ pagination.html โโโ registration โย ย โโโ logged_out.html โย ย โโโ password_change_done.html โย ย โโโ password_change_form.html โย ย โโโ password_reset_complete.html โย ย โโโ password_reset_confirm.html โย ย โโโ password_reset_done.html โย ย โโโ password_reset_form.html โโโ shop โโโ components โย ย โโโ _carousel.html โย ย โโโ _highlights.html โย ย โโโ _instagramSection.html โย ย โโโ _swiper.html โย ย โโโ _videoSection.html โโโ home.html