Skip to content

Commit b94eaa0

Browse files
author
shashwatkathuria
committed
Added webpack configuration.
1 parent 5ab9e13 commit b94eaa0

File tree

1 file changed

+105
-0
lines changed

1 file changed

+105
-0
lines changed

webpack.config.js

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
const HtmlWebPackPlugin = require('html-webpack-plugin');
2+
const WebpackPwaManifest = require('webpack-pwa-manifest');
3+
const ServiceWorkerWebpackPlugin = require('serviceworker-webpack-plugin');
4+
const path = require('path');
5+
6+
module.exports = {
7+
entry: path.resolve(__dirname, 'src/assets/index.js'),
8+
output: {
9+
globalObject: 'this'
10+
},
11+
module: {
12+
rules: [
13+
{
14+
test: /\.(js|jsx)$/,
15+
exclude: /node_modules/,
16+
use: {
17+
loader: 'babel-loader'
18+
}
19+
},
20+
{
21+
test: /\.html$/,
22+
use: [
23+
{
24+
loader: 'html-loader'
25+
}
26+
]
27+
},
28+
{
29+
test: /\.css$/,
30+
use: [
31+
// Creates `style` nodes from JS strings
32+
'style-loader',
33+
// Translates CSS into CommonJS
34+
'css-loader'
35+
]
36+
},
37+
{
38+
test: /\.(scss)$/,
39+
use: [
40+
// Creates `style` nodes from JS strings
41+
'style-loader',
42+
// Translates CSS into CommonJS
43+
'css-loader',
44+
// Compiles Sass to CSS
45+
'sass-loader',
46+
]
47+
},
48+
{
49+
test: /\.(png|jpe?g|gif|pdf)$/i,
50+
loader: 'file-loader',
51+
options: {
52+
name: '[name].[ext]',
53+
outputPath: 'assets',
54+
}
55+
}
56+
]
57+
},
58+
plugins: [
59+
// Progressive Web Application Manifest, i.e., <link rel='manifest' href='manifest.json'>
60+
// Manifest config
61+
// GitHub: https://github.com/arthurbergmz/webpack-pwa-manifest
62+
new WebpackPwaManifest({
63+
filename: 'manifest.json',
64+
name: 'PWA',
65+
short_name: 'PWA',
66+
description: 'PWA',
67+
icons: [
68+
{
69+
// Icon name and its multiple sizes
70+
src: path.resolve('src/assets/images/app-icon.png'),
71+
sizes: [96, 144, 192, 256]
72+
}, {
73+
src: path.resolve('src/assets/images/app-icon.png'),
74+
sizes: [96, 144, 192, 256],
75+
ios: true
76+
}, {
77+
src: path.resolve('src/assets/images/app-icon.png'),
78+
sizes: 256,
79+
ios: 'startup'
80+
}
81+
],
82+
orientation: 'portrait',
83+
display: 'standalone',
84+
start_url: '/',
85+
fingerprints: false,
86+
crossorigin: null,
87+
background_color: '#000000',
88+
theme_color: '#000000',
89+
ios: {
90+
'apple-mobile-web-app-title': 'PWA',
91+
'apple-mobile-web-app-status-bar-style': 'black'
92+
}
93+
}),
94+
// Entry point for service worker
95+
new ServiceWorkerWebpackPlugin({
96+
entry: path.join(__dirname, 'src/assets/sw.js'),
97+
}),
98+
// Entry point for all assets except service worker
99+
new HtmlWebPackPlugin({
100+
favicon: './src/assets/favicon.png',
101+
template: './src/assets/index.html',
102+
filename: './index.html'
103+
})
104+
]
105+
};

0 commit comments

Comments
 (0)