function build()

in build.js [29:68]


function build() {
    function bundleJS(files) {
        const output = [];
        for  (let filePath of files) {
            output.push(fs.readFileSync(
                path.resolve(__dirname, filePath), 'utf-8'
            ));
        }
        const outputCode = output.join('\n');
        const result = UglifyJS.minify(outputCode, {
            mangle: true
        });
        return result.code;
    }

    // Bundle sass
    const cssResult = sass.renderSync({
        file: path.resolve(__dirname, 'app/styles/main.scss'),
        outputStyle: 'compressed'
    });

    ['en', 'zh'].forEach(function (lang) {
        const jsPostfix = lang === 'en' ? '_en' : '';
        fs.writeFileSync(path.resolve(__dirname, `app/${lang}/theme-builder/app.min.js`), bundleJS([
            `app/scripts/components${jsPostfix}.js`,
            `app/scripts/options${jsPostfix}.js`,
            `app/scripts/main${jsPostfix}.js`
        ]), 'utf-8');
        // Write css
        fs.writeFileSync(path.resolve(__dirname, `app/${lang}/theme-builder/main.css`), cssResult.css);

        // Build html
        fs.writeFileSync(
            path.resolve(__dirname, `app/${lang}/index.html`),
            htmlTpl.replace('{{body}}', fs.readFileSync(path.resolve(__dirname, `app/${lang}/body.html`)), )
        );

        copydir.sync(path.resolve(__dirname, 'app/themes'), `app/${lang}/theme-builder/themes`);
    });
}