Last active
March 11, 2020 05:58
-
-
Save marcosrjjunior/1277797db577085e7d3d318b82d9a339 to your computer and use it in GitHub Desktop.
react simple 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
// .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