Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- "build": "rm -rf public && npm run build:webpack && npm run build:hugo",
- "build:hugo": "hugo -d ../public -s site -v",
- "build:webpack": "cross-env NODE_ENV=production webpack --config webpack.prod.js --hot --inline"
- const webpack = require("webpack");
- const path = require("path");
- const CopyWebpackPlugin = require("copy-webpack-plugin");
- const MiniCssExtractPlugin = require("mini-css-extract-plugin");
- const AssetsPlugin = require("assets-webpack-plugin");
- module.exports = {
- entry: {
- main: path.join(__dirname, "src", "index.js")
- },
- output: {
- path: path.join(__dirname, "public")
- },
- module: {
- rules: [
- {
- test: /.((png)|(eot)|(woff)|(woff2)|(ttf)|(svg)|(gif))(?v=d+.d+.d+)?$/,
- loader: "file-loader?name=/[hash].[ext]"
- },
- {test: /.json$/, loader: "json-loader"},
- {
- loader: "babel-loader",
- test: /.js?$/,
- exclude: /node_modules/,
- query: {cacheDirectory: true}
- },
- {
- test: /.(sa|sc|c)ss$/,
- exclude: /node_modules/,
- use: ["style-loader", MiniCssExtractPlugin.loader, "css-loader", "postcss-loader"]
- }
- ]
- },
- plugins: [
- new webpack.ProvidePlugin({
- fetch: "imports-loader?this=>global!exports-loader?global.fetch!whatwg-fetch"
- }),
- new CopyWebpackPlugin([
- {
- from: "./src/fonts/",
- to: "fonts/",
- flatten: true
- }
- ]),
- new CopyWebpackPlugin([
- {
- from: "./node_modules/@ionic/core/",
- to: "ionic/core/",
- ignore: ['*.ts', '*.scss', '*e2e.js'],
- flatten: false
- }
- ]),
- new AssetsPlugin({
- filename: "webpack.json",
- path: path.join(process.cwd(), "site/data"),
- prettyPrint: true
- })
- ]
- };
- const merge = require("webpack-merge");
- const TerserPlugin = require('terser-webpack-plugin');
- const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");
- const MiniCssExtractPlugin = require("mini-css-extract-plugin");
- const common = require("./webpack.common.js");
- const {InjectManifest, GenerateSW} = require('workbox-webpack-plugin');
- module.exports = merge(common, {
- mode: "production",
- output: {
- filename: "[name].[hash:5].js",
- chunkFilename: "[id].[hash:5].css"
- },
- optimization: {
- minimizer: [
- new TerserPlugin({
- cache: true,
- parallel: true,
- sourceMap: true
- }),
- new MiniCssExtractPlugin({
- filename: "[name].[hash:5].css",
- chunkFilename: "[id].[hash:5].css"
- }),
- new OptimizeCSSAssetsPlugin({}),
- ]
- },
- plugins: [
- new InjectManifest({
- swSrc: './src/sw.js',
- exclude: [/.md$/, /.xml$/, /.txt$/, /.json$/, /.keep$/, /.DS_Store$/, '404.html', '404/index.html']
- }),
- ]
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement