Skip to content

Instantly share code, notes, and snippets.

@paulallies
Last active April 3, 2020 16:26
Show Gist options
  • Save paulallies/9b4d7fe16b2c7949add98c75b7959367 to your computer and use it in GitHub Desktop.
Save paulallies/9b4d7fe16b2c7949add98c75b7959367 to your computer and use it in GitHub Desktop.
webpack for without-react-create-app
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