<commit_before>'use strict';
const webpack = require('webpack');
const path = require('path');
const fs = require('fs');
const os = require('os');
const ini = require('ini');

const ExtractTextPlugin = require("extract-text-webpack-plugin");
const WebpackConfig = require('webpack-config');
const BowerResolvePlugin = require("bower-resolve-webpack-plugin");
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');

const loadTranslations = require('../trl/load-translations');
const lookupVendorPoFiles = require('../trl/lookup-vendor-po-files');
const lookupSassIncludePaths = require('../loader/lookup-sass-include-paths');
const lookupAliasPaths = require('../loader/lookup-alias-paths');
const TrlPlugin = require("../trl/trl-plugin");
const fetchLanguages = require("../loader/fetch-languages");
const fetchKwfConfig = require("./fetch-kwf-config");

var extractCssPlugin = new ExtractTextPlugin("./[name].css");
const kwfConfig = fetchKwfConfig();

const langauges = fetchLanguages();

const configIni = ini.parse(fs.readFileSync('config.ini', 'utf-8'));
const webCodeLangauge = configIni.production.webCodeLanguage;
const uniquePrefix = configIni.production['application.uniquePrefix'];

const devBuild = !!process.env.KWF_BUILD_DEV;

let plugins = [
    new TrlPlugin({
        uniquePrefix: uniquePrefix,
        languages: langauges,
        webCodeLanguage: webCodeLangauge,
        translations: {
            web: loadTranslations(['trl/[language].po'], langauges),
            kwf: loadTranslations(lookupVendorPoFiles(), langauges),
        }
    }),
    extractCssPlugin,
    /*
     new webpack.ResolverPlugin([
     new webpack.ResolverPlugin.DirectoryDescriptionFilePlugin(".bower.json", ["main"])
     ], ['normal']),
     */
];
if (!devBuild) {
    plugins.push(new UglifyJSPlugin());
}

//console.log(WebpackConfig.environment);
//console.log(WebpackConfig.Config);

module.exports = {
    //devtool: "source-map", // or "inline-source-map"
    output: {
        //path: __dirname + "/build/assets",
        path: process.cwd()+"/build/assets",
        publicPath: (kwfConfig['webpack-dev-server-url'] ? kwfConfig['webpack-dev-server-url'] : '/') + "assets/build/",
        filename: '[name].js',
        chunkFilename: "[id].js",
        pathinfo: devBuild //Include comments with information about the modules
    },
    module: {
        rules: [{
            test: /\.underscore\.tpl$/,
            loader: "underscore-template-loader",
            options: {
                engine: 'underscore'
            }
        },{
            enforce: 'post',
            test: /\.s?css$/,
            loader: extractCssPlugin.extract({
                use: "css-loader",<commit_msg>add uniquePrefix to webpackJsonp method name<commit_after>'use strict';
const webpack = require('webpack');
const path = require('path');
const fs = require('fs');
const os = require('os');
const ini = require('ini');

const ExtractTextPlugin = require("extract-text-webpack-plugin");
const WebpackConfig = require('webpack-config');
const BowerResolvePlugin = require("bower-resolve-webpack-plugin");
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');

const loadTranslations = require('../trl/load-translations');
const lookupVendorPoFiles = require('../trl/lookup-vendor-po-files');
const lookupSassIncludePaths = require('../loader/lookup-sass-include-paths');
const lookupAliasPaths = require('../loader/lookup-alias-paths');
const TrlPlugin = require("../trl/trl-plugin");
const fetchLanguages = require("../loader/fetch-languages");
const fetchKwfConfig = require("./fetch-kwf-config");

var extractCssPlugin = new ExtractTextPlugin("./[name].css");
const kwfConfig = fetchKwfConfig();

const langauges = fetchLanguages();

const configIni = ini.parse(fs.readFileSync('config.ini', 'utf-8'));
const webCodeLangauge = configIni.production.webCodeLanguage;
const uniquePrefix = configIni.production['application.uniquePrefix'];

const devBuild = !!process.env.KWF_BUILD_DEV;

let plugins = [
    new TrlPlugin({
        uniquePrefix: uniquePrefix,
        languages: langauges,
        webCodeLanguage: webCodeLangauge,
        translations: {
            web: loadTranslations(['trl/[language].po'], langauges),
            kwf: loadTranslations(lookupVendorPoFiles(), langauges),
        }
    }),
    extractCssPlugin,
    /*
     new webpack.ResolverPlugin([
     new webpack.ResolverPlugin.DirectoryDescriptionFilePlugin(".bower.json", ["main"])
     ], ['normal']),
     */
];
if (!devBuild) {
    plugins.push(new UglifyJSPlugin());
}

//console.log(WebpackConfig.environment);
//console.log(WebpackConfig.Config);

module.exports = {
    //devtool: "source-map", // or "inline-source-map"
    output: {
        //path: __dirname + "/build/assets",
        path: process.cwd()+"/build/assets",
        publicPath: (kwfConfig['webpack-dev-server-url'] ? kwfConfig['webpack-dev-server-url'] : '/') + "assets/build/",
        filename: '[name].js',
        chunkFilename: "[id].js",
        jsonpFunction: uniquePrefix+'webpackJsonp',
        pathinfo: devBuild //Include comments with information about the modules
    },
    module: {
        rules: [{
            test: /\.underscore\.tpl$/,
            loader: "underscore-template-loader",
            options: {
                engine: 'underscore'
            }
        },{
            enforce: 'post',
            test: /\.s?css$/,
            loader: extractCssPlugin.extract({
                use: "css-loader",
{'fraction_non_alphanumeric': 0.1567449481157837, 'fraction_numerical': 0.0003640997633351538, 'mean_word_length': 3.332807570977918, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '135454', 'n_tokens_mistral': 1619, 'n_tokens_neox': 1595, 'n_words': 302}