const path = require('path')
module.exports = {
+ mode: 'development',
entry: './src/js/main.js',
output: {
filename: 'main.js',
We're including a little bit of Bootstrap styling here with the `div class="container"` and `<button>` so that we see when Bootstrap's CSS is loaded by Webpack.
-3. **Now we need an npm script to run Webpack.** Open `package.json` and add the `start` script shown below (you should already have the test script). We'll use this script to start our local Webpack dev server.
+3. **Now we need an npm script to run Webpack.** Open `package.json` and add the `start` script shown below (you should already have the test script). We'll use this script to start our local Webpack dev server. You can also add a `build` script shown below to build your project.
```json
{
// ...
"scripts": {
- "start": "webpack serve --mode development",
+ "start": "webpack serve",
+ "build": "webpack build",
"test": "echo \"Error: no test specified\" && exit 1"
},
// ...
const path = require('path')
module.exports = {
+ mode: 'development',
entry: './src/js/main.js',
output: {
filename: 'main.js',
test: /\.(scss)$/,
use: [
{
+ // Adds CSS to the DOM by injecting a `<style>` tag
loader: 'style-loader'
},
{
+ // Interprets `@import` and `url()` like `import/require()` and will resolve them
loader: 'css-loader'
},
{
+ // Loader for webpack to process CSS with PostCSS
loader: 'postcss-loader',
options: {
postcssOptions: {
}
},
{
+ // Loads a SASS/SCSS file and compiles it to CSS
loader: 'sass-loader'
}
]