pk-webpack v1.0.1
wip: pk-webpack
Get Started
Add as dev dependency for any pk- module.
pk- module installation
From within your
pk-module project, add both awebpack-dev.jsand awebpack-prod.jsfile. These will handle both dev environments.Inside your
package.json, add them as executablenpmscripts:
package.json
...
"scripts": {
"dev": "node webpack-dev.js",
"prod": "node webpack-prod.js"
},- Following the syntax below, add these into your executable
webpack-x.jsfiles:
webpack-dev.js
...
const pkWebpack = require('pk-webpack');
const path = require('path');
const appRoot = path.resolve(__dirname, '../');
const config = {
'mode': 'development'
};
pkWebpack(appRoot, config);This initializes Webpack with the proper dev environment, and passes along the root of the project for proper "build" context. In other words, it gives Webpack knowledge of where to look for, and compile assets. "mode" could either be development or production, depending on the context and the file that you're in. This gets merged with Webpack's standard configuration object, so you can pass other parameters here as well.
pk-webpackwill look inside yoursrcfolder for javascript, and sass files withinjs, andscssfolders respectively. Following best practices, the entry points are/src/js/site.jsand/src/scss/site.scss.pk-webpackwill build these files into your/publicdirectory asalways.cssandalways.jsfiles, that yourpk-module must push in afterConstruct.
Watching & Dev
Running npm run dev from within your pk- module will start Webpack in watch mode.
Build & Production
Running npm run prod will simply run Webpack once to build the files
3 years ago