Skip to content

Instantly share code, notes, and snippets.

@YonatanKra
Last active January 17, 2018 08:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save YonatanKra/0b86594406c9f25c23c595eeaf9f8683 to your computer and use it in GitHub Desktop.
Save YonatanKra/0b86594406c9f25c23c595eeaf9f8683 to your computer and use it in GitHub Desktop.
First webpack config for the webpack guide
const path = require('path');
const webpack = require('webpack');
// require our plugins
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
module.exports = {
entry: './src/app.js', // this is our app
output: {
filename: '[name].bundle.js', // the file name would be my entry's name with a ".bundle.js" suffix
path: path.resolve(__dirname, 'dist') // put all of the build in a dist folder
},
plugins: [
new UglifyJsPlugin({
sourceMap: true
}),
new CleanWebpackPlugin(['dist']), // use the clean plugin to delete the dist folder before a build
// This plugin creates our index.html that would load the app for us in the browser
new HtmlWebpackPlugin({
title: 'Your Phrase Fireworks!'
})
],
module: {
rules: [
// use the html loader
{
test: /\.html$/,
exclude: /node_modules/,
use: {loader: 'html-loader'}
},
// use the css loaders (first load the css, then inject the style)
{
test: /\.css$/,
use: [
'style-loader',
'css-loader'
]
}
]
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment