Last active
April 3, 2020 16:26
-
-
Save paulallies/9b4d7fe16b2c7949add98c75b7959367 to your computer and use it in GitHub Desktop.
webpack for without-react-create-app
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 path = require("path"); | |
const HtmlWebPackPlugin = require("html-webpack-plugin"); | |
const ExtractTextPlugin = require("extract-text-webpack-plugin"); | |
module.exports = { | |
devtool: 'source-map', | |
entry: "./src/index.js", | |
output: { | |
path: path.join(__dirname, "/dist"), | |
filename: "index_bundle.js" | |
}, | |
module: { | |
rules: [{ | |
test: /\.js$/, | |
exclude: /node_modules/, | |
use: { | |
loader: 'babel-loader', | |
options: { | |
presets: ['@babel/preset-react'] | |
} | |
} | |
}, { | |
test: /\.css$/, | |
use: ExtractTextPlugin.extract( | |
{ | |
fallback: 'style-loader', | |
use: ['css-loader'] | |
} | |
) | |
}, | |
{ | |
test: /\.(png|jpg|gif)$/, | |
use: [ | |
{ | |
loader: 'file-loader' | |
} | |
] | |
} | |
] | |
}, | |
plugins: [ | |
new HtmlWebPackPlugin({ | |
hash: true, | |
filename: "index.html", //target html | |
template: "./src/public/index.html" //source html | |
}), | |
new ExtractTextPlugin({ filename: 'css/style.css' }) | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment