Last active
February 16, 2018 20:08
-
-
Save jayjariwala/8933371f5dab4aa9395d1e9b4b871e33 to your computer and use it in GitHub Desktop.
Webpack config essential plugins and loaders
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
| //plugins | |
| html-webpack-plugin -load javascript file dynamically | |
| clean-webpack-plugin -clean distribution folder. | |
| //css loaders | |
| style-loader | |
| css-loader | |
| //basic demo file | |
| const path = require('path'); | |
| const HtmlWebpackPlugin = require('html-webpack-plugin'); | |
| const CleanWebpackPlugin = require('clean-webpack-plugin'); | |
| const webpack = require('webpack'); | |
| module.exports = { | |
| entry: { | |
| App : './src/app.js' | |
| }, | |
| devtool: 'inline-source-map', | |
| devServer: { | |
| contentBase: './dist', | |
| hot:true | |
| }, | |
| plugins: [ | |
| new HtmlWebpackPlugin({ | |
| title:"development" | |
| }), | |
| new CleanWebpackPlugin(['dist']), | |
| new webpack.NamedModulesPlugin(), | |
| new webpack.HotModuleReplacementPlugin() | |
| ], | |
| output: { | |
| filename: '[name].bundle.js', | |
| path: path.resolve(__dirname,'dist') | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment