<commit_before>import fs from "fs"
import path from "path"
import webpack from "webpack"
import ExtractTextPlugin from "extract-text-webpack-plugin"

import markdownIt from "markdown-it"
import markdownItTocAndAnchor from "markdown-it-toc-and-anchor"
import hljs from "highlight.js"

import pkg from "../package.json"

import builder from "statinamic/lib/builder"
import configurator from "statinamic/lib/configurator"
import prepareDefinedValues from "statinamic/lib/prepare-defined-values"

const config = configurator(pkg)

const sourceBase = "content"
const destBase = "dist"
const root = path.join(__dirname, "..")
const source = path.join(root, sourceBase)
const dest = path.join(root, destBase)

const webpackConfig = {
  devtool: "eval",

  output: {
    path: dest,
    filename: "[name].js",
    publicPath: config.baseUrl.path,
  },

  resolve: {
    extensions: [
      // node default extensions
      ".js",
      ".json",
      // for all other extensions specified directly
      "",
    ],

    root: [
      path.join(root, "node_modules"),
      path.join(root, "web_modules"), // for static (node) build
    ],
  },

  resolveLoader: {
    root: [ path.join(root, "node_modules") ],
  },

  module: {
    // ! \\ note that loaders are executed from bottom to top !
    loaders: [
      //
      // statinamic requirement
      //
      {
        test: /\.md$/,
        loader: "statinamic/lib/md-collection-loader" +
          `?${ JSON.stringify({
            context: source,
            basepath: config.baseUrl.path,
            defaultHead: {
              layout: "Post",
              comments: true,
            },
            feedsOptions: {
              title: pkg.name,
              site_url: pkg.homepage,
            },
            feeds: {
              "feed.xml": {
                collectionOptions: {
                  filter: { layout: "Post" },
                  sort: "date",
                  reverse: true,
                  limit: 20,
                },
              },
            },
          }) }`
        ,
      },
      {
        test: /\.json$/,
        loader: "json-loader",
      },

      // your loaders
      {
        test: /\.js$/,
        loaders: [
          "babel-loader",
          "eslint-loader", // ?fix",
        ],
        exclude: /(statinamic|node_modules)/,
      },
      // css modules
      {
        test: /styles\.css$/,
        loader: ExtractTextPlugin.extract(
          "style-loader",
          [
            "css-loader" + "?" + [
              `localIdentName=${
                config.dev
                ? "[path][name]--[local]--[hash:base64:5]"
                : "[hash:base64]"
              }`,
              "modules",
            ].join("&"),
            "postcss-loader",
          ].join("!"),
        ),
      },
      // for legacy css
      // when this is unused (= we use only css modules)
      // close this
      // https://github.com/putaindecode/putaindecode.io/issues/509
      {
        test: /legacy-css(\/|\\).*\.css$/,
        loader: ExtractTextPlugin.extract(
          "style-loader",
          [
            "css-loader",
            "postcss-loader",
          ].join("!"),
        ),
      },
      {
        test: /content(\/|\\).*\.(html|ico|jpe?g|png|gif)$/,
        loader: "file-loader?name=[path][name].[ext]&context=./content",
      },
      {
        test: /web_modules(\/|\\).*\.(html|ico|jpe?g|png|gif)$/,
        loader: "file-loader?name=_/[path][name].[ext]&context=./web_modules",
      },
      {
        test: /^CNAME$/,
        loader: "file-loader?name=[path][name].[ext]&context=./content",
      },
      {
        test: /\.(svg)$/,
        loaders : [
          "raw-loader",
          "svgo-loader?useConfig=svgo",
        ],
      },
    ],
  },

  svgo: {
    plugins: [
      { removeTitle: true, removeDesc: true },
      { convertColors: { shorthex: false } },<commit_msg>Remove useless loader for CNAME<commit_after>import fs from "fs"
import path from "path"
import webpack from "webpack"
import ExtractTextPlugin from "extract-text-webpack-plugin"

import markdownIt from "markdown-it"
import markdownItTocAndAnchor from "markdown-it-toc-and-anchor"
import hljs from "highlight.js"

import pkg from "../package.json"

import builder from "statinamic/lib/builder"
import configurator from "statinamic/lib/configurator"
import prepareDefinedValues from "statinamic/lib/prepare-defined-values"

const config = configurator(pkg)

const sourceBase = "content"
const destBase = "dist"
const root = path.join(__dirname, "..")
const source = path.join(root, sourceBase)
const dest = path.join(root, destBase)

const webpackConfig = {
  devtool: "eval",

  output: {
    path: dest,
    filename: "[name].js",
    publicPath: config.baseUrl.path,
  },

  resolve: {
    extensions: [
      // node default extensions
      ".js",
      ".json",
      // for all other extensions specified directly
      "",
    ],

    root: [
      path.join(root, "node_modules"),
      path.join(root, "web_modules"), // for static (node) build
    ],
  },

  resolveLoader: {
    root: [ path.join(root, "node_modules") ],
  },

  module: {
    // ! \\ note that loaders are executed from bottom to top !
    loaders: [
      //
      // statinamic requirement
      //
      {
        test: /\.md$/,
        loader: "statinamic/lib/md-collection-loader" +
          `?${ JSON.stringify({
            context: source,
            basepath: config.baseUrl.path,
            defaultHead: {
              layout: "Post",
              comments: true,
            },
            feedsOptions: {
              title: pkg.name,
              site_url: pkg.homepage,
            },
            feeds: {
              "feed.xml": {
                collectionOptions: {
                  filter: { layout: "Post" },
                  sort: "date",
                  reverse: true,
                  limit: 20,
                },
              },
            },
          }) }`
        ,
      },
      {
        test: /\.json$/,
        loader: "json-loader",
      },

      // your loaders
      {
        test: /\.js$/,
        loaders: [
          "babel-loader",
          "eslint-loader", // ?fix",
        ],
        exclude: /(statinamic|node_modules)/,
      },
      // css modules
      {
        test: /styles\.css$/,
        loader: ExtractTextPlugin.extract(
          "style-loader",
          [
            "css-loader" + "?" + [
              `localIdentName=${
                config.dev
                ? "[path][name]--[local]--[hash:base64:5]"
                : "[hash:base64]"
              }`,
              "modules",
            ].join("&"),
            "postcss-loader",
          ].join("!"),
        ),
      },
      // for legacy css
      // when this is unused (= we use only css modules)
      // close this
      // https://github.com/putaindecode/putaindecode.io/issues/509
      {
        test: /legacy-css(\/|\\).*\.css$/,
        loader: ExtractTextPlugin.extract(
          "style-loader",
          [
            "css-loader",
            "postcss-loader",
          ].join("!"),
        ),
      },
      {
        test: /content(\/|\\).*\.(html|ico|jpe?g|png|gif)$/,
        loader: "file-loader?name=[path][name].[ext]&context=./content",
      },
      {
        test: /web_modules(\/|\\).*\.(html|ico|jpe?g|png|gif)$/,
        loader: "file-loader?name=_/[path][name].[ext]&context=./web_modules",
      },
      {
        test: /\.(svg)$/,
        loaders : [
          "raw-loader",
          "svgo-loader?useConfig=svgo",
        ],
      },
    ],
  },

  svgo: {
    plugins: [
      { removeTitle: true, removeDesc: true },
      { convertColors: { shorthex: false } },
{'fraction_non_alphanumeric': 0.15751389068355084, 'fraction_numerical': 0.002584313218762114, 'mean_word_length': 1.5468904244817374, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5127574', 'n_tokens_mistral': 2404, 'n_tokens_neox': 2314, 'n_words': 448}