Created
December 29, 2017 06:24
-
-
Save garciamax/5b2b626231072381b4c7bbc649ec3a1d to your computer and use it in GitHub Desktop.
webpack + react + babel
This file contains 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
Show hidden characters
{ | |
"presets": ["env", "react"] | |
} |
This file contains 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
npm i webpack babel-loader babel-core babel-preset-env babel-preset-react react react-dom prop-types html-webpack-plugin html-loader --save-dev |
This file contains 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
"scripts": { | |
"build": "webpack" | |
} |
This file contains 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"); | |
module.exports = { | |
entry: ["./src/js/app.js"], | |
output: { | |
path: path.resolve(__dirname, "dist"), | |
filename: "js/[name].js" | |
}, | |
module: { | |
rules: [ | |
{ | |
test: /\.js$/, | |
exclude: /node_modules/, | |
use: { | |
loader: "babel-loader" | |
} | |
}, | |
{ | |
test: /\.html$/, | |
use: [ | |
{ | |
loader: "html-loader" | |
} | |
] | |
} | |
] | |
}, | |
plugins: [ | |
new HtmlWebPackPlugin({ | |
template: "./src/index.html", | |
filename: "./index.html" | |
}) | |
] | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment