This is for when you use the WordPress Plugin Boilerplate generator as starter for a WordPress plugin.
This is a way to get Sass set up and have Javascript use module dependency with webpack as the module bundler.
Follow the steps below to get started.
- Run the terminal command in
create-folders-and-files.txt
.
This will create the the src Javacript and Sass files as shown in the structure below.
.
├── admin
│ └── src
│ ├── js
│ │ ├── index.js
│ │ └── lib
│ │ └── component.js
│ └── scss
│ └── main.scss
└── public
└── src
├── js
│ ├── index.js
│ └── lib
│ └── component.js
└── scss
└── main.scss
- Create the
package.json
file copy the package.json file located in this gist.
npm init -y
- Create the
gulpfile.js
file and copy the contents from here.
touch gulpfile.js
-
Edit the
const
in the gulbfile fromwebpack
(line 1) to whatever the plugin is. -
Add the npm depenencies.
npm install
To watch files
$ npm start
To build files for production.
$ npm run build