Skip to content

Instantly share code, notes, and snippets.

@marcosrjjunior
Last active March 11, 2020 05:58
Show Gist options
  • Save marcosrjjunior/1277797db577085e7d3d318b82d9a339 to your computer and use it in GitHub Desktop.
Save marcosrjjunior/1277797db577085e7d3d318b82d9a339 to your computer and use it in GitHub Desktop.
react simple webpack
// .babelrc
{
"presets": [
"@babel/preset-env",
"@babel/preset-react"
],
"plugins": [
"@babel/plugin-transform-runtime",
"@babel/plugin-proposal-class-properties"
]
}
// .webpack.common.js
const path = require('path');
module.exports = {
entry: './src/index.js',
plugins: [],
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: ['babel-loader'],
},
{
test: /\.(scss|css)$/,
use: [
'style-loader', // creates style nodes from JS strings
'css-loader', // translates CSS into CommonJS
'sass-loader', // compiles Sass to CSS, using Node Sass by default
],
},
{
test: /\.(png|jpg|gif|svg)$/i,
use: [
{
loader: 'url-loader',
},
],
},
],
},
output: {
path: __dirname + '/build',
publicPath: '/',
filename: 'bundle.js',
// filename: 'bundle.js',
// path: path.resolve(__dirname, 'dist'),
},
};
// scripts
"build": "webpack --mode production --config webpack.common.js"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment