Example #1
0
File: ghu.js Project: lrsjng/kjua
ghu.task('build:script', runtime => {
    const webpackConfig = {
        mode: 'none',
        output: {
            library: NAME,
            libraryTarget: 'umd',
            umdNamedDefine: true,
            globalObject: '(typeof self !== \'undefined\' ? self : this)'
        },
        module: {
            rules: [
                {
                    include: [SRC],
                    loader: 'babel-loader',
                    query: {
                        cacheDirectory: true,
                        presets: ['@babel/preset-env']
                    }
                }
            ]
        }
    };

    return read(`${SRC}/${NAME}.js`)
        .then(webpack(webpackConfig, {showStats: false}))
        .then(includeit())
        .then(uglify())
        .then(wrap(runtime.commentJs))
        .then(write(`${DIST}/${NAME}.min.js`, {overwrite: true}))
        .then(write(`${BUILD}/${NAME}-${runtime.pkg.version}.min.js`, {overwrite: true}));
});
Example #2
0
ghu.task('build:other', runtime => {
    return Promise.all([
        read(`${SRC}/**/*.pug`)
            .then(pug({pkg: runtime.pkg}))
            .then(write(mapfn.p(SRC, BUILD).s('.pug', ''), {overwrite: true})),
        read(`${SRC}/**/*.less`)
            .then(includeit())
            .then(less())
            .then(cssmin())
            .then(write(mapfn.p(SRC, BUILD).s('.less', '.css'), {overwrite: true})),
        read(`${SRC}/demo/*.js, ${SRC}/test/*.js`)
            .then(babel({presets: ['@babel/preset-env']}))
            .then(uglify())
            .then(wrap(runtime.commentJs))
            .then(write(mapfn.p(SRC, BUILD), {overwrite: true})),

        read(`${ROOT}/node_modules/scar/dist/scar.min.js`)
            .then(write(`${BUILD}/test/scar.min.js`, {overwrite: true})),
        read(`${ROOT}/node_modules/jquery/dist/jquery.min.js`)
            .then(write(`${BUILD}/demo/jquery.min.js`, {overwrite: true}))
            .then(write(`${BUILD}/test/jquery.min.js`, {overwrite: true})),

        read(`${ROOT}/*.md`)
            .then(write(mapfn.p(ROOT, BUILD), {overwrite: true}))
    ]);
});
Example #3
0
ghu.task('build:scripts', runtime => {
    return read(`${SRC}/${NAME}.js`)
        .then(includeit())
        .then(wrap(runtime.commentJs))
        .then(write(`${DIST}/${NAME}.js`, {overwrite: true}))
        .then(write(`${BUILD}/${NAME}-${runtime.pkg.version}.js`, {overwrite: true}))
        .then(uglify({compressor: {warnings: false}}))
        .then(wrap(runtime.commentJs))
        .then(write(`${DIST}/${NAME}.min.js`, {overwrite: true}))
        .then(write(`${BUILD}/${NAME}-${runtime.pkg.version}.min.js`, {overwrite: true}));
});