Skip to content

Instantly share code, notes, and snippets.

@josefaidt
Created July 11, 2018 20:39
Show Gist options
  • Save josefaidt/f7d5addae8b3cfa13663bfb95bf16388 to your computer and use it in GitHub Desktop.
Save josefaidt/f7d5addae8b3cfa13663bfb95bf16388 to your computer and use it in GitHub Desktop.
First Webpack config - sass, images, fonts, and babel
const HtmlWebpackPlugin = require('html-webpack-plugin')
const path = require('path')
module.exports = {
entry: './src/index.js',
output: {
filename: 'main.js',
path: path.resolve(__dirname, 'dist')
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['env']
}
}
},
{
test: /\.(png|svg|jpg|gif)$/,
use: ['file-loader']
},
{
test: /\.scss$/,
use: [
'style-loader', // creates style nodes from JS strings
'css-loader', // translates CSS into CommonJS
'sass-loader' // compiles Sass to CSS
]
},
{
test: /\.(woff|woff2|eot|ttf|otf)$/,
use: ['file-loader']
}
]
},
plugins: [
new HtmlWebpackPlugin({template: './src/index.html'})
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment