Skip to content

Instantly share code, notes, and snippets.

@harshaktg
harshaktg / api.js
Created September 8, 2020 13:40
API file
export const fetchTodos = () => {
return fetch('https://jsonplaceholder.typicode.com/posts')
.then(response => response.json())
.then(json => json);
}
module.exports = {
optimization: {
splitChunks: { chunks: "all" }
}
};
@harshaktg
harshaktg / package.json
Created September 8, 2020 13:02
Webpack package json production
"scripts": {
"dev": "webpack --mode development",
"start": "webpack-dev-server --mode development --open",
"build": "webpack --mode production"
}
@harshaktg
harshaktg / webpack.config.js
Created September 8, 2020 12:52
Webpack configuration babel
module.exports = {
module: {
rules: [
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
},
{
test: /\.scss$/,
use: ['style-loader', 'css-loader', 'sass-loader']
@harshaktg
harshaktg / babel.config.json
Created September 8, 2020 12:21
Babel configuration
{
"presets": ["@babel/preset-env"]
}
@harshaktg
harshaktg / webpack.config.js
Last active September 8, 2020 11:19
Webpack scss config
module.exports = {
module: {
rules: [
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
},
{
test: /\.scss$/,
use: ['style-loader', 'css-loader', 'sass-loader']
@harshaktg
harshaktg / styles.scss
Created September 8, 2020 11:16
Styles scss
$primary-bg: aqua;
body {
background-color: $primary-bg;
}
@harshaktg
harshaktg / webpack.config.js
Created September 8, 2020 11:03
Webpack CSS loaders
module.exports = {
module: {
rules: [
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
}
]
}
};
@harshaktg
harshaktg / index.js
Last active September 8, 2020 11:00
Index file after including css
import './styles.css';
console.log('Im from source!');
@harshaktg
harshaktg / webpack.config.js
Created September 8, 2020 10:30
Webpack loader example
module.exports = {
module: {
rules: [
{
test: /\.filename1$/,
use: ["loader-b", "loader-a"]
},
{
test: /\.filename2$/,
use: ["loader-d", "loader-c"]