Created
July 11, 2018 20:39
-
-
Save josefaidt/f7d5addae8b3cfa13663bfb95bf16388 to your computer and use it in GitHub Desktop.
First Webpack config - sass, images, fonts, and babel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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