Skip to content

Commit e3cba33

Browse files
authored
Add files via upload
0 parents  commit e3cba33

File tree

8 files changed

+6829
-0
lines changed

8 files changed

+6829
-0
lines changed

bundler/webpack.common.js

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
const CopyWebpackPlugin = require('copy-webpack-plugin')
2+
const HtmlWebpackPlugin = require('html-webpack-plugin')
3+
const MiniCSSExtractPlugin = require('mini-css-extract-plugin')
4+
const path = require('path')
5+
6+
module.exports = {
7+
entry: path.resolve(__dirname, '../src/script.js'),
8+
output:
9+
{
10+
filename: 'bundle.[contenthash].js',
11+
path: path.resolve(__dirname, '../dist')
12+
},
13+
devtool: 'source-map',
14+
plugins:
15+
[
16+
new CopyWebpackPlugin({
17+
patterns: [
18+
{ from: path.resolve(__dirname, '../static') }
19+
]
20+
}),
21+
new HtmlWebpackPlugin({
22+
template: path.resolve(__dirname, '../src/index.html'),
23+
minify: true
24+
}),
25+
new MiniCSSExtractPlugin()
26+
],
27+
module:
28+
{
29+
rules:
30+
[
31+
// HTML
32+
{
33+
test: /\.(html)$/,
34+
use: ['html-loader']
35+
},
36+
37+
// JS
38+
{
39+
test: /\.js$/,
40+
exclude: /node_modules/,
41+
use:
42+
[
43+
'babel-loader'
44+
]
45+
},
46+
47+
// CSS
48+
{
49+
test: /\.css$/,
50+
use:
51+
[
52+
MiniCSSExtractPlugin.loader,
53+
'css-loader'
54+
]
55+
},
56+
57+
// Images
58+
{
59+
test: /\.(jpg|png|gif|svg)$/,
60+
use:
61+
[
62+
{
63+
loader: 'file-loader',
64+
options:
65+
{
66+
outputPath: 'assets/images/'
67+
}
68+
}
69+
]
70+
},
71+
72+
// Fonts
73+
{
74+
test: /\.(ttf|eot|woff|woff2)$/,
75+
use:
76+
[
77+
{
78+
loader: 'file-loader',
79+
options:
80+
{
81+
outputPath: 'assets/fonts/'
82+
}
83+
}
84+
]
85+
}
86+
]
87+
}
88+
}

bundler/webpack.dev.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
const { merge } = require('webpack-merge')
2+
const commonConfiguration = require('./webpack.common.js')
3+
const ip = require('internal-ip')
4+
const portFinderSync = require('portfinder-sync')
5+
6+
const infoColor = (_message) =>
7+
{
8+
return `\u001b[1m\u001b[34m${_message}\u001b[39m\u001b[22m`
9+
}
10+
11+
module.exports = merge(
12+
commonConfiguration,
13+
{
14+
mode: 'development',
15+
devServer:
16+
{
17+
host: '0.0.0.0',
18+
port: portFinderSync.getPort(8080),
19+
contentBase: './dist',
20+
watchContentBase: true,
21+
open: true,
22+
https: false,
23+
useLocalIp: true,
24+
disableHostCheck: true,
25+
overlay: true,
26+
noInfo: true,
27+
after: function(app, server, compiler)
28+
{
29+
const port = server.options.port
30+
const https = server.options.https ? 's' : ''
31+
const localIp = ip.v4.sync()
32+
const domain1 = `http${https}://${localIp}:${port}`
33+
const domain2 = `http${https}://localhost:${port}`
34+
35+
console.log(`Project running at:\n - ${infoColor(domain1)}\n - ${infoColor(domain2)}`)
36+
}
37+
}
38+
}
39+
)

bundler/webpack.prod.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const { merge } = require('webpack-merge')
2+
const commonConfiguration = require('./webpack.common.js')
3+
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
4+
5+
module.exports = merge(
6+
commonConfiguration,
7+
{
8+
mode: 'production',
9+
plugins:
10+
[
11+
new CleanWebpackPlugin()
12+
]
13+
}
14+
)

0 commit comments

Comments
 (0)