2020-02-06 12:27:58 -05:00
|
|
|
const path = require('path');
|
|
|
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
|
|
const GoogleFontsPlugin = require('@beyonk/google-fonts-webpack-plugin');
|
|
|
|
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
2020-02-28 10:00:41 -05:00
|
|
|
const LicensePlugin = require('webpack-license-plugin');
|
2020-03-07 10:46:39 -05:00
|
|
|
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
2020-02-06 12:27:58 -05:00
|
|
|
|
2020-03-03 22:12:11 -05:00
|
|
|
const now = new Date();
|
2020-03-03 22:13:45 -05:00
|
|
|
const year = now.getFullYear().toString();
|
2020-03-03 22:12:11 -05:00
|
|
|
const releaseDate = now.getFullYear() + "-" + (now.getMonth() + 1).toString().padStart(2, '0') + "-" + now.getDate().toString().padStart(2, '0');
|
|
|
|
|
2020-02-06 12:27:58 -05:00
|
|
|
module.exports = {
|
2020-03-13 21:35:35 -04:00
|
|
|
entry: {
|
|
|
|
index: './src/index.js',
|
|
|
|
sw: './src/sw.js'
|
|
|
|
},
|
2020-02-06 12:27:58 -05:00
|
|
|
plugins: [
|
|
|
|
new CleanWebpackPlugin(),
|
|
|
|
new HtmlWebpackPlugin({
|
2020-03-13 21:35:35 -04:00
|
|
|
excludeChunks: ['sw'],
|
2020-03-07 10:46:39 -05:00
|
|
|
template: 'src/index.html'
|
2020-02-06 12:27:58 -05:00
|
|
|
}),
|
|
|
|
new GoogleFontsPlugin({
|
|
|
|
fonts: [
|
|
|
|
{ family: "Material Icons" }
|
|
|
|
],
|
|
|
|
local: false
|
|
|
|
}),
|
2020-03-07 10:46:39 -05:00
|
|
|
new LicensePlugin(),
|
2020-03-07 10:48:15 -05:00
|
|
|
new CopyWebpackPlugin([
|
|
|
|
{
|
|
|
|
from: 'src/icon/*.png', to: 'icons', flatten: true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
from: 'src/icon/safari-pinned-tab.svg', to: 'icons'
|
|
|
|
},
|
|
|
|
{
|
2020-03-12 20:30:20 -04:00
|
|
|
from: 'src/icon/favicon.ico', to: 'icons'
|
2020-03-07 10:48:15 -05:00
|
|
|
},
|
|
|
|
{
|
|
|
|
from: 'src/icon/site.webmanifest', to: 'icons'
|
|
|
|
},
|
2020-03-07 10:46:39 -05:00
|
|
|
{
|
2020-03-07 10:48:15 -05:00
|
|
|
from: 'src/icon/browserconfig.xml', to: 'icons'
|
2020-03-07 10:46:39 -05:00
|
|
|
}
|
2020-03-07 10:48:15 -05:00
|
|
|
])
|
2020-02-06 12:27:58 -05:00
|
|
|
],
|
|
|
|
output: {
|
2020-03-13 21:35:35 -04:00
|
|
|
filename: '[name].js',
|
2020-02-06 12:27:58 -05:00
|
|
|
path: path.resolve(__dirname, 'dist')
|
|
|
|
},
|
|
|
|
module: {
|
|
|
|
rules: [
|
2020-03-07 10:46:39 -05:00
|
|
|
{
|
|
|
|
test: /\.html$/,
|
|
|
|
loader: 'html-loader',
|
|
|
|
options: {
|
|
|
|
interpolate: true
|
|
|
|
}
|
|
|
|
},
|
2020-02-06 12:27:58 -05:00
|
|
|
{
|
|
|
|
test: /\.svelte$/,
|
|
|
|
exclude: /node_modules/,
|
2020-02-28 10:00:41 -05:00
|
|
|
use: [
|
|
|
|
'svelte-loader',
|
|
|
|
{
|
|
|
|
loader: 'string-replace-loader',
|
|
|
|
options: {
|
|
|
|
multiple: [
|
2020-03-03 22:12:11 -05:00
|
|
|
{ search: '|BUILD_YEAR|', replace: year },
|
|
|
|
{ search: '|BUILD_DATE|', replace: releaseDate}
|
2020-02-28 10:00:41 -05:00
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
2020-02-06 12:27:58 -05:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.css$/,
|
|
|
|
use: [
|
|
|
|
'style-loader',
|
|
|
|
'css-loader'
|
|
|
|
]
|
2020-03-12 20:30:20 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.png$/,
|
|
|
|
loader: 'file-loader'
|
2020-02-06 12:27:58 -05:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
}
|