@ray-js/builder-web 0.3.0-beta.1c347991
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/build.d.ts +5 -0
 - package/lib/build.js +254 -0
 - package/lib/index.d.ts +2 -0
 - package/lib/index.js +8 -0
 - package/lib/loaders/process-css.d.ts +2 -0
 - package/lib/loaders/process-css.js +50 -0
 - package/lib/loaders/process-less.d.ts +2 -0
 - package/lib/loaders/process-less.js +56 -0
 - package/package.json +67 -0
 - package/views/index.ejs +35 -0
 
    
        package/lib/build.d.ts
    ADDED
    
    
    
        package/lib/build.js
    ADDED
    
    | 
         @@ -0,0 +1,254 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            "use strict";
         
     | 
| 
      
 2 
     | 
    
         
            +
            var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
         
     | 
| 
      
 3 
     | 
    
         
            +
                function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
         
     | 
| 
      
 4 
     | 
    
         
            +
                return new (P || (P = Promise))(function (resolve, reject) {
         
     | 
| 
      
 5 
     | 
    
         
            +
                    function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
         
     | 
| 
      
 6 
     | 
    
         
            +
                    function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
         
     | 
| 
      
 7 
     | 
    
         
            +
                    function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
         
     | 
| 
      
 8 
     | 
    
         
            +
                    step((generator = generator.apply(thisArg, _arguments || [])).next());
         
     | 
| 
      
 9 
     | 
    
         
            +
                });
         
     | 
| 
      
 10 
     | 
    
         
            +
            };
         
     | 
| 
      
 11 
     | 
    
         
            +
            var __importDefault = (this && this.__importDefault) || function (mod) {
         
     | 
| 
      
 12 
     | 
    
         
            +
                return (mod && mod.__esModule) ? mod : { "default": mod };
         
     | 
| 
      
 13 
     | 
    
         
            +
            };
         
     | 
| 
      
 14 
     | 
    
         
            +
            Object.defineProperty(exports, "__esModule", { value: true });
         
     | 
| 
      
 15 
     | 
    
         
            +
            const address_1 = __importDefault(require("address"));
         
     | 
| 
      
 16 
     | 
    
         
            +
            const case_sensitive_paths_webpack_plugin_1 = __importDefault(require("case-sensitive-paths-webpack-plugin"));
         
     | 
| 
      
 17 
     | 
    
         
            +
            const colors_1 = __importDefault(require("colors"));
         
     | 
| 
      
 18 
     | 
    
         
            +
            const copy_webpack_plugin_1 = __importDefault(require("copy-webpack-plugin"));
         
     | 
| 
      
 19 
     | 
    
         
            +
            const detect_port_1 = __importDefault(require("detect-port"));
         
     | 
| 
      
 20 
     | 
    
         
            +
            const fs_extra_1 = __importDefault(require("fs-extra"));
         
     | 
| 
      
 21 
     | 
    
         
            +
            const hard_source_webpack_plugin_1 = __importDefault(require("hard-source-webpack-plugin"));
         
     | 
| 
      
 22 
     | 
    
         
            +
            const html_webpack_plugin_1 = __importDefault(require("html-webpack-plugin"));
         
     | 
| 
      
 23 
     | 
    
         
            +
            const inquirer_1 = __importDefault(require("inquirer"));
         
     | 
| 
      
 24 
     | 
    
         
            +
            const path_1 = __importDefault(require("path"));
         
     | 
| 
      
 25 
     | 
    
         
            +
            const webpack_1 = __importDefault(require("webpack"));
         
     | 
| 
      
 26 
     | 
    
         
            +
            const webpack_bundle_analyzer_1 = require("webpack-bundle-analyzer");
         
     | 
| 
      
 27 
     | 
    
         
            +
            const webpack_chain_1 = __importDefault(require("webpack-chain"));
         
     | 
| 
      
 28 
     | 
    
         
            +
            const webpack_dev_server_1 = __importDefault(require("webpack-dev-server"));
         
     | 
| 
      
 29 
     | 
    
         
            +
            const webpackbar_1 = __importDefault(require("webpackbar"));
         
     | 
| 
      
 30 
     | 
    
         
            +
            const shared_1 = require("@ray-js/shared");
         
     | 
| 
      
 31 
     | 
    
         
            +
            const process_css_1 = require("./loaders/process-css");
         
     | 
| 
      
 32 
     | 
    
         
            +
            const process_less_1 = require("./loaders/process-less");
         
     | 
| 
      
 33 
     | 
    
         
            +
            colors_1.default.enable();
         
     | 
| 
      
 34 
     | 
    
         
            +
            const LOG_PREFIX = 'builder-web';
         
     | 
| 
      
 35 
     | 
    
         
            +
            function build(options, context) {
         
     | 
| 
      
 36 
     | 
    
         
            +
                return __awaiter(this, void 0, void 0, function* () {
         
     | 
| 
      
 37 
     | 
    
         
            +
                    const { api } = context;
         
     | 
| 
      
 38 
     | 
    
         
            +
                    const compileOptions = Object.assign({
         
     | 
| 
      
 39 
     | 
    
         
            +
                        cwd: process.cwd(),
         
     | 
| 
      
 40 
     | 
    
         
            +
                        mode: 'development',
         
     | 
| 
      
 41 
     | 
    
         
            +
                        watch: false,
         
     | 
| 
      
 42 
     | 
    
         
            +
                        analyze: false,
         
     | 
| 
      
 43 
     | 
    
         
            +
                        mini: false,
         
     | 
| 
      
 44 
     | 
    
         
            +
                        source: 'src',
         
     | 
| 
      
 45 
     | 
    
         
            +
                        output: 'dist',
         
     | 
| 
      
 46 
     | 
    
         
            +
                        target: 'web',
         
     | 
| 
      
 47 
     | 
    
         
            +
                        port: '8088',
         
     | 
| 
      
 48 
     | 
    
         
            +
                        https: false,
         
     | 
| 
      
 49 
     | 
    
         
            +
                    }, options);
         
     | 
| 
      
 50 
     | 
    
         
            +
                    const { cwd, mode, output, target, analyze, watch, mini, source, port, https } = compileOptions;
         
     | 
| 
      
 51 
     | 
    
         
            +
                    process.env.NODE_ENV = mode;
         
     | 
| 
      
 52 
     | 
    
         
            +
                    process.env.PLATFORM = 'web';
         
     | 
| 
      
 53 
     | 
    
         
            +
                    process.env.REMAX_PLATFORM = 'web';
         
     | 
| 
      
 54 
     | 
    
         
            +
                    const outputPath = (0, shared_1.resolvePath)([output, target], { cwd });
         
     | 
| 
      
 55 
     | 
    
         
            +
                    const isDev = mode !== 'production';
         
     | 
| 
      
 56 
     | 
    
         
            +
                    const isProd = mode === 'production';
         
     | 
| 
      
 57 
     | 
    
         
            +
                    const config = new webpack_chain_1.default();
         
     | 
| 
      
 58 
     | 
    
         
            +
                    config.mode(mode);
         
     | 
| 
      
 59 
     | 
    
         
            +
                    if (isDev) {
         
     | 
| 
      
 60 
     | 
    
         
            +
                        const devtool = isDev ? 'cheap-module-eval-source-map' : 'source-map';
         
     | 
| 
      
 61 
     | 
    
         
            +
                        config.devtool(devtool);
         
     | 
| 
      
 62 
     | 
    
         
            +
                        shared_1.log.info(LOG_PREFIX, 'enabled webpack devtool SourceMap '.yellow);
         
     | 
| 
      
 63 
     | 
    
         
            +
                    }
         
     | 
| 
      
 64 
     | 
    
         
            +
                    config.context(cwd);
         
     | 
| 
      
 65 
     | 
    
         
            +
                    config.output.path(outputPath).publicPath('/');
         
     | 
| 
      
 66 
     | 
    
         
            +
                    config.resolve.extensions.merge([
         
     | 
| 
      
 67 
     | 
    
         
            +
                        '.web.tsx',
         
     | 
| 
      
 68 
     | 
    
         
            +
                        '.web.jsx',
         
     | 
| 
      
 69 
     | 
    
         
            +
                        '.web.ts',
         
     | 
| 
      
 70 
     | 
    
         
            +
                        '.web.js',
         
     | 
| 
      
 71 
     | 
    
         
            +
                        '.tsx',
         
     | 
| 
      
 72 
     | 
    
         
            +
                        '.jsx',
         
     | 
| 
      
 73 
     | 
    
         
            +
                        '.ts',
         
     | 
| 
      
 74 
     | 
    
         
            +
                        '.js',
         
     | 
| 
      
 75 
     | 
    
         
            +
                        '.json',
         
     | 
| 
      
 76 
     | 
    
         
            +
                    ]);
         
     | 
| 
      
 77 
     | 
    
         
            +
                    config.resolve.alias.merge({
         
     | 
| 
      
 78 
     | 
    
         
            +
                        '@': path_1.default.resolve(cwd, source),
         
     | 
| 
      
 79 
     | 
    
         
            +
                        '@babel/runtime': path_1.default.dirname(require.resolve('@babel/runtime/package.json')),
         
     | 
| 
      
 80 
     | 
    
         
            +
                    });
         
     | 
| 
      
 81 
     | 
    
         
            +
                    // 启动页面
         
     | 
| 
      
 82 
     | 
    
         
            +
                    config.entry('main').add('./.ray/main.tsx');
         
     | 
| 
      
 83 
     | 
    
         
            +
                    // babel-loader
         
     | 
| 
      
 84 
     | 
    
         
            +
                    config.module
         
     | 
| 
      
 85 
     | 
    
         
            +
                        .rule('js')
         
     | 
| 
      
 86 
     | 
    
         
            +
                        .test(/\.(ts|js)x?$/)
         
     | 
| 
      
 87 
     | 
    
         
            +
                        .exclude.add(/node_modules/)
         
     | 
| 
      
 88 
     | 
    
         
            +
                        .end()
         
     | 
| 
      
 89 
     | 
    
         
            +
                        .use('babel-loader')
         
     | 
| 
      
 90 
     | 
    
         
            +
                        .loader(require.resolve('babel-loader'))
         
     | 
| 
      
 91 
     | 
    
         
            +
                        .options({
         
     | 
| 
      
 92 
     | 
    
         
            +
                        presets: [[require.resolve('@ray-js/babel-preset-standard')]],
         
     | 
| 
      
 93 
     | 
    
         
            +
                    })
         
     | 
| 
      
 94 
     | 
    
         
            +
                        .end()
         
     | 
| 
      
 95 
     | 
    
         
            +
                        .use('env-loader')
         
     | 
| 
      
 96 
     | 
    
         
            +
                        .loader(require.resolve('@ray-js/env-loader'))
         
     | 
| 
      
 97 
     | 
    
         
            +
                        .options({
         
     | 
| 
      
 98 
     | 
    
         
            +
                        platform: 'web',
         
     | 
| 
      
 99 
     | 
    
         
            +
                    })
         
     | 
| 
      
 100 
     | 
    
         
            +
                        .end();
         
     | 
| 
      
 101 
     | 
    
         
            +
                    (0, process_css_1.processCss)(config);
         
     | 
| 
      
 102 
     | 
    
         
            +
                    (0, process_less_1.processLess)(config);
         
     | 
| 
      
 103 
     | 
    
         
            +
                    config.optimization
         
     | 
| 
      
 104 
     | 
    
         
            +
                        .minimize(mini)
         
     | 
| 
      
 105 
     | 
    
         
            +
                        .runtimeChunk({ name: 'runtime' })
         
     | 
| 
      
 106 
     | 
    
         
            +
                        .noEmitOnErrors(watch)
         
     | 
| 
      
 107 
     | 
    
         
            +
                        .splitChunks({
         
     | 
| 
      
 108 
     | 
    
         
            +
                        chunks: 'all',
         
     | 
| 
      
 109 
     | 
    
         
            +
                        maxInitialRequests: Infinity,
         
     | 
| 
      
 110 
     | 
    
         
            +
                        minSize: 0,
         
     | 
| 
      
 111 
     | 
    
         
            +
                        name: isDev,
         
     | 
| 
      
 112 
     | 
    
         
            +
                        cacheGroups: {
         
     | 
| 
      
 113 
     | 
    
         
            +
                            // 项目内公用的
         
     | 
| 
      
 114 
     | 
    
         
            +
                            common: {
         
     | 
| 
      
 115 
     | 
    
         
            +
                                name: 'common',
         
     | 
| 
      
 116 
     | 
    
         
            +
                                minChunks: 2,
         
     | 
| 
      
 117 
     | 
    
         
            +
                                priority: -20,
         
     | 
| 
      
 118 
     | 
    
         
            +
                                reuseExistingChunk: true,
         
     | 
| 
      
 119 
     | 
    
         
            +
                            },
         
     | 
| 
      
 120 
     | 
    
         
            +
                            // 依赖中公用的
         
     | 
| 
      
 121 
     | 
    
         
            +
                            vendors: {
         
     | 
| 
      
 122 
     | 
    
         
            +
                                name: 'vendors',
         
     | 
| 
      
 123 
     | 
    
         
            +
                                chunks: 'initial',
         
     | 
| 
      
 124 
     | 
    
         
            +
                                minChunks: 2,
         
     | 
| 
      
 125 
     | 
    
         
            +
                                test: /[\\/]node_modules[\\/]/,
         
     | 
| 
      
 126 
     | 
    
         
            +
                                priority: -10,
         
     | 
| 
      
 127 
     | 
    
         
            +
                                reuseExistingChunk: true,
         
     | 
| 
      
 128 
     | 
    
         
            +
                            },
         
     | 
| 
      
 129 
     | 
    
         
            +
                        },
         
     | 
| 
      
 130 
     | 
    
         
            +
                    });
         
     | 
| 
      
 131 
     | 
    
         
            +
                    config.performance.hints(false);
         
     | 
| 
      
 132 
     | 
    
         
            +
                    config.plugin('defined').use(webpack_1.default.DefinePlugin, [
         
     | 
| 
      
 133 
     | 
    
         
            +
                        {
         
     | 
| 
      
 134 
     | 
    
         
            +
                            'process.env.NODE_ENV': JSON.stringify(mode),
         
     | 
| 
      
 135 
     | 
    
         
            +
                            'process.env.PLATFORM': JSON.stringify(target),
         
     | 
| 
      
 136 
     | 
    
         
            +
                        },
         
     | 
| 
      
 137 
     | 
    
         
            +
                    ]);
         
     | 
| 
      
 138 
     | 
    
         
            +
                    analyze && config.plugin('bundle-analyzer-plugin').use(webpack_bundle_analyzer_1.BundleAnalyzerPlugin);
         
     | 
| 
      
 139 
     | 
    
         
            +
                    config.plugin('case-sensitive-paths-webpack-plugin').use(case_sensitive_paths_webpack_plugin_1.default);
         
     | 
| 
      
 140 
     | 
    
         
            +
                    isDev && config.plugin('hard-source-webpack-plugin').use(hard_source_webpack_plugin_1.default);
         
     | 
| 
      
 141 
     | 
    
         
            +
                    isProd &&
         
     | 
| 
      
 142 
     | 
    
         
            +
                        config.plugin('webpack.HashedModuleIdsPlugin').use(webpack_1.default.HashedModuleIdsPlugin, [
         
     | 
| 
      
 143 
     | 
    
         
            +
                            {
         
     | 
| 
      
 144 
     | 
    
         
            +
                                hashFunction: 'sha256',
         
     | 
| 
      
 145 
     | 
    
         
            +
                                hashDigest: 'hex',
         
     | 
| 
      
 146 
     | 
    
         
            +
                                hashDigestLength: 20,
         
     | 
| 
      
 147 
     | 
    
         
            +
                            },
         
     | 
| 
      
 148 
     | 
    
         
            +
                        ]);
         
     | 
| 
      
 149 
     | 
    
         
            +
                    config.plugin('webpackbar').use(webpackbar_1.default, [{ name: 'web' }]);
         
     | 
| 
      
 150 
     | 
    
         
            +
                    config.plugin('html-webpack-plugin').use(html_webpack_plugin_1.default, [
         
     | 
| 
      
 151 
     | 
    
         
            +
                        {
         
     | 
| 
      
 152 
     | 
    
         
            +
                            template: path_1.default.join(__dirname, '../views/index.ejs'),
         
     | 
| 
      
 153 
     | 
    
         
            +
                            chunks: ['main'],
         
     | 
| 
      
 154 
     | 
    
         
            +
                            filename: 'index.html',
         
     | 
| 
      
 155 
     | 
    
         
            +
                        },
         
     | 
| 
      
 156 
     | 
    
         
            +
                    ]);
         
     | 
| 
      
 157 
     | 
    
         
            +
                    const publicDir = path_1.default.join(cwd, 'public');
         
     | 
| 
      
 158 
     | 
    
         
            +
                    if (fs_extra_1.default.existsSync(publicDir)) {
         
     | 
| 
      
 159 
     | 
    
         
            +
                        shared_1.log.info(LOG_PREFIX, 'copy public folder files'.yellow, publicDir.underline.blue);
         
     | 
| 
      
 160 
     | 
    
         
            +
                        config.plugin('copy').use(copy_webpack_plugin_1.default, [
         
     | 
| 
      
 161 
     | 
    
         
            +
                            {
         
     | 
| 
      
 162 
     | 
    
         
            +
                                patterns: [
         
     | 
| 
      
 163 
     | 
    
         
            +
                                    {
         
     | 
| 
      
 164 
     | 
    
         
            +
                                        from: path_1.default.join(cwd, 'public'),
         
     | 
| 
      
 165 
     | 
    
         
            +
                                        to({ absoluteFilename }) {
         
     | 
| 
      
 166 
     | 
    
         
            +
                                            return `${path_1.default.relative(publicDir, absoluteFilename)}`;
         
     | 
| 
      
 167 
     | 
    
         
            +
                                        },
         
     | 
| 
      
 168 
     | 
    
         
            +
                                    },
         
     | 
| 
      
 169 
     | 
    
         
            +
                                ],
         
     | 
| 
      
 170 
     | 
    
         
            +
                            },
         
     | 
| 
      
 171 
     | 
    
         
            +
                        ]);
         
     | 
| 
      
 172 
     | 
    
         
            +
                    }
         
     | 
| 
      
 173 
     | 
    
         
            +
                    api.callPluginMethod('configWebpack', { config });
         
     | 
| 
      
 174 
     | 
    
         
            +
                    const externals = config.get('externals');
         
     | 
| 
      
 175 
     | 
    
         
            +
                    const internalExternals = {
         
     | 
| 
      
 176 
     | 
    
         
            +
                        react: 'React',
         
     | 
| 
      
 177 
     | 
    
         
            +
                        'react-dom': 'ReactDOM',
         
     | 
| 
      
 178 
     | 
    
         
            +
                    };
         
     | 
| 
      
 179 
     | 
    
         
            +
                    if (Array.isArray('externals')) {
         
     | 
| 
      
 180 
     | 
    
         
            +
                        config.set('externals', [...externals, internalExternals]);
         
     | 
| 
      
 181 
     | 
    
         
            +
                    }
         
     | 
| 
      
 182 
     | 
    
         
            +
                    else {
         
     | 
| 
      
 183 
     | 
    
         
            +
                        config.set('externals', Object.assign(Object.assign({}, externals), internalExternals));
         
     | 
| 
      
 184 
     | 
    
         
            +
                    }
         
     | 
| 
      
 185 
     | 
    
         
            +
                    api.configIntoWebpackConfig(config);
         
     | 
| 
      
 186 
     | 
    
         
            +
                    if (watch) {
         
     | 
| 
      
 187 
     | 
    
         
            +
                        const defaultHttpPort = parseInt(port);
         
     | 
| 
      
 188 
     | 
    
         
            +
                        const httpPort = yield (0, detect_port_1.default)(defaultHttpPort);
         
     | 
| 
      
 189 
     | 
    
         
            +
                        if (httpPort != defaultHttpPort) {
         
     | 
| 
      
 190 
     | 
    
         
            +
                            const { ok } = yield inquirer_1.default.prompt([
         
     | 
| 
      
 191 
     | 
    
         
            +
                                {
         
     | 
| 
      
 192 
     | 
    
         
            +
                                    name: 'ok',
         
     | 
| 
      
 193 
     | 
    
         
            +
                                    type: 'confirm',
         
     | 
| 
      
 194 
     | 
    
         
            +
                                    prefix: defaultHttpPort,
         
     | 
| 
      
 195 
     | 
    
         
            +
                                    suffix: httpPort,
         
     | 
| 
      
 196 
     | 
    
         
            +
                                    message: 'Server port conflict, use the new port instead? ',
         
     | 
| 
      
 197 
     | 
    
         
            +
                                },
         
     | 
| 
      
 198 
     | 
    
         
            +
                            ]);
         
     | 
| 
      
 199 
     | 
    
         
            +
                            if (!ok) {
         
     | 
| 
      
 200 
     | 
    
         
            +
                                process.exit(0);
         
     | 
| 
      
 201 
     | 
    
         
            +
                            }
         
     | 
| 
      
 202 
     | 
    
         
            +
                        }
         
     | 
| 
      
 203 
     | 
    
         
            +
                        let devOptions = {
         
     | 
| 
      
 204 
     | 
    
         
            +
                            contentBase: outputPath,
         
     | 
| 
      
 205 
     | 
    
         
            +
                            compress: true,
         
     | 
| 
      
 206 
     | 
    
         
            +
                            hot: true,
         
     | 
| 
      
 207 
     | 
    
         
            +
                            open: false,
         
     | 
| 
      
 208 
     | 
    
         
            +
                            historyApiFallback: true,
         
     | 
| 
      
 209 
     | 
    
         
            +
                            disableHostCheck: true,
         
     | 
| 
      
 210 
     | 
    
         
            +
                            port: httpPort,
         
     | 
| 
      
 211 
     | 
    
         
            +
                            publicPath: '/',
         
     | 
| 
      
 212 
     | 
    
         
            +
                            stats: {
         
     | 
| 
      
 213 
     | 
    
         
            +
                                colors: true,
         
     | 
| 
      
 214 
     | 
    
         
            +
                                modules: false,
         
     | 
| 
      
 215 
     | 
    
         
            +
                            },
         
     | 
| 
      
 216 
     | 
    
         
            +
                        };
         
     | 
| 
      
 217 
     | 
    
         
            +
                        const ip = address_1.default.ip();
         
     | 
| 
      
 218 
     | 
    
         
            +
                        const compiler = (0, webpack_1.default)(config.toConfig());
         
     | 
| 
      
 219 
     | 
    
         
            +
                        const server = new webpack_dev_server_1.default(compiler, devOptions);
         
     | 
| 
      
 220 
     | 
    
         
            +
                        server.listen(httpPort, '0.0.0.0', () => {
         
     | 
| 
      
 221 
     | 
    
         
            +
                            console.log();
         
     | 
| 
      
 222 
     | 
    
         
            +
                            shared_1.log.info('[wds]', 'HTTP local      :', `http://127.0.0.1:${httpPort}`.blue.underline);
         
     | 
| 
      
 223 
     | 
    
         
            +
                            shared_1.log.info('[wds]', 'HTTP network    :', `http://${ip}:${httpPort}`.blue.underline);
         
     | 
| 
      
 224 
     | 
    
         
            +
                            console.log();
         
     | 
| 
      
 225 
     | 
    
         
            +
                        });
         
     | 
| 
      
 226 
     | 
    
         
            +
                        return Promise.resolve(compiler);
         
     | 
| 
      
 227 
     | 
    
         
            +
                    }
         
     | 
| 
      
 228 
     | 
    
         
            +
                    else {
         
     | 
| 
      
 229 
     | 
    
         
            +
                        return new Promise((resolve) => {
         
     | 
| 
      
 230 
     | 
    
         
            +
                            const compiler = (0, webpack_1.default)(config.toConfig());
         
     | 
| 
      
 231 
     | 
    
         
            +
                            compiler.run((error, stats) => {
         
     | 
| 
      
 232 
     | 
    
         
            +
                                if (error) {
         
     | 
| 
      
 233 
     | 
    
         
            +
                                    shared_1.log.error(LOG_PREFIX, error.message);
         
     | 
| 
      
 234 
     | 
    
         
            +
                                    throw error;
         
     | 
| 
      
 235 
     | 
    
         
            +
                                }
         
     | 
| 
      
 236 
     | 
    
         
            +
                                const info = stats.toJson();
         
     | 
| 
      
 237 
     | 
    
         
            +
                                if (stats.hasErrors()) {
         
     | 
| 
      
 238 
     | 
    
         
            +
                                    shared_1.log.error(LOG_PREFIX, info.errors.join('\n'));
         
     | 
| 
      
 239 
     | 
    
         
            +
                                    process.exit(1);
         
     | 
| 
      
 240 
     | 
    
         
            +
                                }
         
     | 
| 
      
 241 
     | 
    
         
            +
                                if (stats.hasWarnings()) {
         
     | 
| 
      
 242 
     | 
    
         
            +
                                    console.warn(info.warnings.join('\n'));
         
     | 
| 
      
 243 
     | 
    
         
            +
                                }
         
     | 
| 
      
 244 
     | 
    
         
            +
                                console.log(stats.toString({
         
     | 
| 
      
 245 
     | 
    
         
            +
                                    colors: true,
         
     | 
| 
      
 246 
     | 
    
         
            +
                                    modules: false,
         
     | 
| 
      
 247 
     | 
    
         
            +
                                }));
         
     | 
| 
      
 248 
     | 
    
         
            +
                            });
         
     | 
| 
      
 249 
     | 
    
         
            +
                            resolve(compiler);
         
     | 
| 
      
 250 
     | 
    
         
            +
                        });
         
     | 
| 
      
 251 
     | 
    
         
            +
                    }
         
     | 
| 
      
 252 
     | 
    
         
            +
                });
         
     | 
| 
      
 253 
     | 
    
         
            +
            }
         
     | 
| 
      
 254 
     | 
    
         
            +
            exports.default = build;
         
     | 
    
        package/lib/index.d.ts
    ADDED
    
    
    
        package/lib/index.js
    ADDED
    
    | 
         @@ -0,0 +1,8 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            "use strict";
         
     | 
| 
      
 2 
     | 
    
         
            +
            var __importDefault = (this && this.__importDefault) || function (mod) {
         
     | 
| 
      
 3 
     | 
    
         
            +
                return (mod && mod.__esModule) ? mod : { "default": mod };
         
     | 
| 
      
 4 
     | 
    
         
            +
            };
         
     | 
| 
      
 5 
     | 
    
         
            +
            Object.defineProperty(exports, "__esModule", { value: true });
         
     | 
| 
      
 6 
     | 
    
         
            +
            exports.build = void 0;
         
     | 
| 
      
 7 
     | 
    
         
            +
            const build_1 = __importDefault(require("./build"));
         
     | 
| 
      
 8 
     | 
    
         
            +
            exports.build = build_1.default;
         
     | 
| 
         @@ -0,0 +1,50 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            "use strict";
         
     | 
| 
      
 2 
     | 
    
         
            +
            var __importDefault = (this && this.__importDefault) || function (mod) {
         
     | 
| 
      
 3 
     | 
    
         
            +
                return (mod && mod.__esModule) ? mod : { "default": mod };
         
     | 
| 
      
 4 
     | 
    
         
            +
            };
         
     | 
| 
      
 5 
     | 
    
         
            +
            Object.defineProperty(exports, "__esModule", { value: true });
         
     | 
| 
      
 6 
     | 
    
         
            +
            exports.processCss = void 0;
         
     | 
| 
      
 7 
     | 
    
         
            +
            const postcss_units_transform_1 = __importDefault(require("postcss-units-transform"));
         
     | 
| 
      
 8 
     | 
    
         
            +
            const autoprefixer_1 = __importDefault(require("autoprefixer"));
         
     | 
| 
      
 9 
     | 
    
         
            +
            const postcss_selector_rename_1 = __importDefault(require("postcss-selector-rename"));
         
     | 
| 
      
 10 
     | 
    
         
            +
            function processCss(config) {
         
     | 
| 
      
 11 
     | 
    
         
            +
                [
         
     | 
| 
      
 12 
     | 
    
         
            +
                    { name: 'less-module', test: /\.module\.css$/, cssModules: true },
         
     | 
| 
      
 13 
     | 
    
         
            +
                    { name: 'css', test: /\.css$/, cssModules: false, exclude: /\.module\.css$/ },
         
     | 
| 
      
 14 
     | 
    
         
            +
                ].forEach(({ test, cssModules, name, exclude }) => {
         
     | 
| 
      
 15 
     | 
    
         
            +
                    const rule = config.module.rule(name).test(test);
         
     | 
| 
      
 16 
     | 
    
         
            +
                    const cssOptions = {
         
     | 
| 
      
 17 
     | 
    
         
            +
                        sourceMap: config.get('mode') === 'development',
         
     | 
| 
      
 18 
     | 
    
         
            +
                        modules: cssModules ? { localIdentName: '[folder]-[local]-[hash:base64:6]' } : false,
         
     | 
| 
      
 19 
     | 
    
         
            +
                    };
         
     | 
| 
      
 20 
     | 
    
         
            +
                    if (exclude) {
         
     | 
| 
      
 21 
     | 
    
         
            +
                        rule.exclude.add(exclude);
         
     | 
| 
      
 22 
     | 
    
         
            +
                    }
         
     | 
| 
      
 23 
     | 
    
         
            +
                    rule.use('style-loader').loader(require.resolve('style-loader'));
         
     | 
| 
      
 24 
     | 
    
         
            +
                    rule.use('css-loader').loader(require.resolve('css-loader')).options(cssOptions);
         
     | 
| 
      
 25 
     | 
    
         
            +
                    rule
         
     | 
| 
      
 26 
     | 
    
         
            +
                        .use('post-loader')
         
     | 
| 
      
 27 
     | 
    
         
            +
                        .loader(require.resolve('postcss-loader'))
         
     | 
| 
      
 28 
     | 
    
         
            +
                        .options({
         
     | 
| 
      
 29 
     | 
    
         
            +
                        ident: 'postcss',
         
     | 
| 
      
 30 
     | 
    
         
            +
                        plugins: [
         
     | 
| 
      
 31 
     | 
    
         
            +
                            (0, autoprefixer_1.default)({ overrideBrowserslist: '>0.25%, not dead' }),
         
     | 
| 
      
 32 
     | 
    
         
            +
                            (0, postcss_selector_rename_1.default)({
         
     | 
| 
      
 33 
     | 
    
         
            +
                                selector: { tags: true },
         
     | 
| 
      
 34 
     | 
    
         
            +
                                rename(name) {
         
     | 
| 
      
 35 
     | 
    
         
            +
                                    return 'ty-' + name;
         
     | 
| 
      
 36 
     | 
    
         
            +
                                },
         
     | 
| 
      
 37 
     | 
    
         
            +
                            }),
         
     | 
| 
      
 38 
     | 
    
         
            +
                            (0, postcss_units_transform_1.default)({
         
     | 
| 
      
 39 
     | 
    
         
            +
                                divisor: 100,
         
     | 
| 
      
 40 
     | 
    
         
            +
                                multiple: 1,
         
     | 
| 
      
 41 
     | 
    
         
            +
                                decimalPlaces: 2,
         
     | 
| 
      
 42 
     | 
    
         
            +
                                comment: 'no',
         
     | 
| 
      
 43 
     | 
    
         
            +
                                targetUnits: 'rem',
         
     | 
| 
      
 44 
     | 
    
         
            +
                                sourceUnits: 'rpx',
         
     | 
| 
      
 45 
     | 
    
         
            +
                            }),
         
     | 
| 
      
 46 
     | 
    
         
            +
                        ],
         
     | 
| 
      
 47 
     | 
    
         
            +
                    });
         
     | 
| 
      
 48 
     | 
    
         
            +
                });
         
     | 
| 
      
 49 
     | 
    
         
            +
            }
         
     | 
| 
      
 50 
     | 
    
         
            +
            exports.processCss = processCss;
         
     | 
| 
         @@ -0,0 +1,56 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            "use strict";
         
     | 
| 
      
 2 
     | 
    
         
            +
            var __importDefault = (this && this.__importDefault) || function (mod) {
         
     | 
| 
      
 3 
     | 
    
         
            +
                return (mod && mod.__esModule) ? mod : { "default": mod };
         
     | 
| 
      
 4 
     | 
    
         
            +
            };
         
     | 
| 
      
 5 
     | 
    
         
            +
            Object.defineProperty(exports, "__esModule", { value: true });
         
     | 
| 
      
 6 
     | 
    
         
            +
            exports.processLess = void 0;
         
     | 
| 
      
 7 
     | 
    
         
            +
            const postcss_units_transform_1 = __importDefault(require("postcss-units-transform"));
         
     | 
| 
      
 8 
     | 
    
         
            +
            const autoprefixer_1 = __importDefault(require("autoprefixer"));
         
     | 
| 
      
 9 
     | 
    
         
            +
            const postcss_selector_rename_1 = __importDefault(require("postcss-selector-rename"));
         
     | 
| 
      
 10 
     | 
    
         
            +
            function processLess(config) {
         
     | 
| 
      
 11 
     | 
    
         
            +
                [
         
     | 
| 
      
 12 
     | 
    
         
            +
                    { name: 'less-module', test: /\.module\.less$/, cssModules: true },
         
     | 
| 
      
 13 
     | 
    
         
            +
                    { name: 'less', test: /\.less$/, cssModules: false, exclude: /\.module\.less$/ },
         
     | 
| 
      
 14 
     | 
    
         
            +
                ].forEach(({ test, cssModules, name, exclude }) => {
         
     | 
| 
      
 15 
     | 
    
         
            +
                    const rule = config.module.rule(name).test(test);
         
     | 
| 
      
 16 
     | 
    
         
            +
                    const cssOptions = {
         
     | 
| 
      
 17 
     | 
    
         
            +
                        sourceMap: config.get('mode') === 'development',
         
     | 
| 
      
 18 
     | 
    
         
            +
                        modules: cssModules ? { localIdentName: '[folder]-[local]-[hash:base64:6]' } : false,
         
     | 
| 
      
 19 
     | 
    
         
            +
                    };
         
     | 
| 
      
 20 
     | 
    
         
            +
                    if (exclude) {
         
     | 
| 
      
 21 
     | 
    
         
            +
                        rule.exclude.add(exclude);
         
     | 
| 
      
 22 
     | 
    
         
            +
                    }
         
     | 
| 
      
 23 
     | 
    
         
            +
                    rule.use('style-loader').loader(require.resolve('style-loader'));
         
     | 
| 
      
 24 
     | 
    
         
            +
                    rule.use('css-loader').loader(require.resolve('css-loader')).options(cssOptions);
         
     | 
| 
      
 25 
     | 
    
         
            +
                    rule
         
     | 
| 
      
 26 
     | 
    
         
            +
                        .use('post-loader')
         
     | 
| 
      
 27 
     | 
    
         
            +
                        .loader(require.resolve('postcss-loader'))
         
     | 
| 
      
 28 
     | 
    
         
            +
                        .options({
         
     | 
| 
      
 29 
     | 
    
         
            +
                        ident: 'postcss',
         
     | 
| 
      
 30 
     | 
    
         
            +
                        plugins: [
         
     | 
| 
      
 31 
     | 
    
         
            +
                            (0, autoprefixer_1.default)({ overrideBrowserslist: '>0.25%, not dead' }),
         
     | 
| 
      
 32 
     | 
    
         
            +
                            (0, postcss_selector_rename_1.default)({
         
     | 
| 
      
 33 
     | 
    
         
            +
                                selector: { tags: true },
         
     | 
| 
      
 34 
     | 
    
         
            +
                                rename(name) {
         
     | 
| 
      
 35 
     | 
    
         
            +
                                    return 'ty-' + name;
         
     | 
| 
      
 36 
     | 
    
         
            +
                                },
         
     | 
| 
      
 37 
     | 
    
         
            +
                            }),
         
     | 
| 
      
 38 
     | 
    
         
            +
                            (0, postcss_units_transform_1.default)({
         
     | 
| 
      
 39 
     | 
    
         
            +
                                divisor: 100,
         
     | 
| 
      
 40 
     | 
    
         
            +
                                multiple: 1,
         
     | 
| 
      
 41 
     | 
    
         
            +
                                decimalPlaces: 2,
         
     | 
| 
      
 42 
     | 
    
         
            +
                                comment: 'no',
         
     | 
| 
      
 43 
     | 
    
         
            +
                                targetUnits: 'rem',
         
     | 
| 
      
 44 
     | 
    
         
            +
                                sourceUnits: 'rpx',
         
     | 
| 
      
 45 
     | 
    
         
            +
                            }),
         
     | 
| 
      
 46 
     | 
    
         
            +
                        ],
         
     | 
| 
      
 47 
     | 
    
         
            +
                    });
         
     | 
| 
      
 48 
     | 
    
         
            +
                    rule
         
     | 
| 
      
 49 
     | 
    
         
            +
                        .use('less-loader')
         
     | 
| 
      
 50 
     | 
    
         
            +
                        .loader('less-loader')
         
     | 
| 
      
 51 
     | 
    
         
            +
                        .options({
         
     | 
| 
      
 52 
     | 
    
         
            +
                        sourceMap: config.get('mode') === 'development',
         
     | 
| 
      
 53 
     | 
    
         
            +
                    });
         
     | 
| 
      
 54 
     | 
    
         
            +
                });
         
     | 
| 
      
 55 
     | 
    
         
            +
            }
         
     | 
| 
      
 56 
     | 
    
         
            +
            exports.processLess = processLess;
         
     | 
    
        package/package.json
    ADDED
    
    | 
         @@ -0,0 +1,67 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            {
         
     | 
| 
      
 2 
     | 
    
         
            +
              "name": "@ray-js/builder-web",
         
     | 
| 
      
 3 
     | 
    
         
            +
              "version": "0.3.0-beta.1c347991",
         
     | 
| 
      
 4 
     | 
    
         
            +
              "description": "Ray builder for web",
         
     | 
| 
      
 5 
     | 
    
         
            +
              "keywords": [
         
     | 
| 
      
 6 
     | 
    
         
            +
                "ray"
         
     | 
| 
      
 7 
     | 
    
         
            +
              ],
         
     | 
| 
      
 8 
     | 
    
         
            +
              "author": "子长 <zichang.nong@tuya.com>",
         
     | 
| 
      
 9 
     | 
    
         
            +
              "license": "MIT",
         
     | 
| 
      
 10 
     | 
    
         
            +
              "main": "lib/index.js",
         
     | 
| 
      
 11 
     | 
    
         
            +
              "files": [
         
     | 
| 
      
 12 
     | 
    
         
            +
                "lib",
         
     | 
| 
      
 13 
     | 
    
         
            +
                "views"
         
     | 
| 
      
 14 
     | 
    
         
            +
              ],
         
     | 
| 
      
 15 
     | 
    
         
            +
              "publishConfig": {
         
     | 
| 
      
 16 
     | 
    
         
            +
                "access": "public",
         
     | 
| 
      
 17 
     | 
    
         
            +
                "registry": "https://registry.npmjs.org"
         
     | 
| 
      
 18 
     | 
    
         
            +
              },
         
     | 
| 
      
 19 
     | 
    
         
            +
              "scripts": {
         
     | 
| 
      
 20 
     | 
    
         
            +
                "clean": "rm -rf lib",
         
     | 
| 
      
 21 
     | 
    
         
            +
                "build": "tsc -p ./tsconfig.build.json",
         
     | 
| 
      
 22 
     | 
    
         
            +
                "watch": "tsc -p ./tsconfig.build.json --watch"
         
     | 
| 
      
 23 
     | 
    
         
            +
              },
         
     | 
| 
      
 24 
     | 
    
         
            +
              "dependencies": {
         
     | 
| 
      
 25 
     | 
    
         
            +
                "@ray-js/babel-preset-standard": "^0.3.0-beta.1c347991",
         
     | 
| 
      
 26 
     | 
    
         
            +
                "@ray-js/env-loader": "^0.3.0-beta.1c347991",
         
     | 
| 
      
 27 
     | 
    
         
            +
                "@ray-js/shared": "^0.3.0-beta.1c347991",
         
     | 
| 
      
 28 
     | 
    
         
            +
                "@ray-js/types": "^0.3.0-beta.1c347991",
         
     | 
| 
      
 29 
     | 
    
         
            +
                "address": "^1.1.2",
         
     | 
| 
      
 30 
     | 
    
         
            +
                "autoprefixer": "9.x",
         
     | 
| 
      
 31 
     | 
    
         
            +
                "camelcase": "^6.2.1",
         
     | 
| 
      
 32 
     | 
    
         
            +
                "case-sensitive-paths-webpack-plugin": "^2.4.0",
         
     | 
| 
      
 33 
     | 
    
         
            +
                "chokidar": "^3.5.2",
         
     | 
| 
      
 34 
     | 
    
         
            +
                "colors": "1.4.0",
         
     | 
| 
      
 35 
     | 
    
         
            +
                "copy-webpack-plugin": "6.x",
         
     | 
| 
      
 36 
     | 
    
         
            +
                "css-loader": "5.x",
         
     | 
| 
      
 37 
     | 
    
         
            +
                "detect-port": "^1.3.0",
         
     | 
| 
      
 38 
     | 
    
         
            +
                "fs-extra": "^10.0.0",
         
     | 
| 
      
 39 
     | 
    
         
            +
                "hard-source-webpack-plugin": "^0.13.1",
         
     | 
| 
      
 40 
     | 
    
         
            +
                "html-webpack-plugin": "4.x",
         
     | 
| 
      
 41 
     | 
    
         
            +
                "inquirer": "^8.2.0",
         
     | 
| 
      
 42 
     | 
    
         
            +
                "less": "^4.1.1",
         
     | 
| 
      
 43 
     | 
    
         
            +
                "less-loader": "7.x",
         
     | 
| 
      
 44 
     | 
    
         
            +
                "postcss-loader": "3.x",
         
     | 
| 
      
 45 
     | 
    
         
            +
                "postcss-selector-rename": "^2.1.0",
         
     | 
| 
      
 46 
     | 
    
         
            +
                "postcss-units-transform": "^1.1.0",
         
     | 
| 
      
 47 
     | 
    
         
            +
                "rimraf": "^3.0.2",
         
     | 
| 
      
 48 
     | 
    
         
            +
                "style-loader": "2.x",
         
     | 
| 
      
 49 
     | 
    
         
            +
                "webpack": "4.x",
         
     | 
| 
      
 50 
     | 
    
         
            +
                "webpack-bundle-analyzer": "^4.5.0",
         
     | 
| 
      
 51 
     | 
    
         
            +
                "webpack-chain": "^6.5.1",
         
     | 
| 
      
 52 
     | 
    
         
            +
                "webpack-dev-server": "^3.0.0",
         
     | 
| 
      
 53 
     | 
    
         
            +
                "webpackbar": "^4.0.0"
         
     | 
| 
      
 54 
     | 
    
         
            +
              },
         
     | 
| 
      
 55 
     | 
    
         
            +
              "devDependencies": {
         
     | 
| 
      
 56 
     | 
    
         
            +
                "@types/node": "^16.9.1",
         
     | 
| 
      
 57 
     | 
    
         
            +
                "typescript": "^4.4.3"
         
     | 
| 
      
 58 
     | 
    
         
            +
              },
         
     | 
| 
      
 59 
     | 
    
         
            +
              "maintainers": [
         
     | 
| 
      
 60 
     | 
    
         
            +
                {
         
     | 
| 
      
 61 
     | 
    
         
            +
                  "name": "tuyafe",
         
     | 
| 
      
 62 
     | 
    
         
            +
                  "email": "tuyafe@tuya.com"
         
     | 
| 
      
 63 
     | 
    
         
            +
                }
         
     | 
| 
      
 64 
     | 
    
         
            +
              ],
         
     | 
| 
      
 65 
     | 
    
         
            +
              "gitHead": "e0bd013022ddda63380d3c9e20fd8cadb46cd61f",
         
     | 
| 
      
 66 
     | 
    
         
            +
              "repository": {}
         
     | 
| 
      
 67 
     | 
    
         
            +
            }
         
     | 
    
        package/views/index.ejs
    ADDED
    
    | 
         @@ -0,0 +1,35 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            <!DOCTYPE html>
         
     | 
| 
      
 2 
     | 
    
         
            +
            <html lang="en">
         
     | 
| 
      
 3 
     | 
    
         
            +
              <head>
         
     | 
| 
      
 4 
     | 
    
         
            +
                <meta charset="UTF-8" />
         
     | 
| 
      
 5 
     | 
    
         
            +
                <meta name="apple-mobile-web-app-title" content="Ray app" />
         
     | 
| 
      
 6 
     | 
    
         
            +
                <meta name="format-detection" content="telephone=no" />
         
     | 
| 
      
 7 
     | 
    
         
            +
                <meta
         
     | 
| 
      
 8 
     | 
    
         
            +
                  name="viewport"
         
     | 
| 
      
 9 
     | 
    
         
            +
                  content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no, viewport-fit=cover" />
         
     | 
| 
      
 10 
     | 
    
         
            +
                <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
         
     | 
| 
      
 11 
     | 
    
         
            +
                <meta http-equiv="Pragma" content="no-cache" />
         
     | 
| 
      
 12 
     | 
    
         
            +
                <meta http-equiv="Expires" content="0" />
         
     | 
| 
      
 13 
     | 
    
         
            +
                <meta name="renderer" content="webkit" />
         
     | 
| 
      
 14 
     | 
    
         
            +
                <meta name="force-rendering" content="webkit" />
         
     | 
| 
      
 15 
     | 
    
         
            +
                <meta name="apple-mobile-web-app-status-bar-style" content="default">
         
     | 
| 
      
 16 
     | 
    
         
            +
                <meta name="apple-mobile-web-app-capable" content="yes" />
         
     | 
| 
      
 17 
     | 
    
         
            +
                <meta name="apple-touch-fullscreen" content="yes" />
         
     | 
| 
      
 18 
     | 
    
         
            +
                <meta name="theme-color" content="#f2f4f6" />
         
     | 
| 
      
 19 
     | 
    
         
            +
                <title>Ray app</title>
         
     | 
| 
      
 20 
     | 
    
         
            +
                <link rel="stylesheet" href="//unpkg.com/normalize.css@8.0.1/normalize.css" />
         
     | 
| 
      
 21 
     | 
    
         
            +
                <script>
         
     | 
| 
      
 22 
     | 
    
         
            +
                  var PUBLIC_PATH = '<%= webpackConfig.output.publicPath %>';
         
     | 
| 
      
 23 
     | 
    
         
            +
                </script>
         
     | 
| 
      
 24 
     | 
    
         
            +
              </head>
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
              <body>
         
     | 
| 
      
 27 
     | 
    
         
            +
                <% if (webpackConfig.mode==='production' ) {%>
         
     | 
| 
      
 28 
     | 
    
         
            +
                <script src="//unpkg.com/react@17.0.2/umd/react.production.min.js"></script>
         
     | 
| 
      
 29 
     | 
    
         
            +
                <script src="//unpkg.com/react-dom@17.0.2/umd/react-dom.production.min.js"></script>
         
     | 
| 
      
 30 
     | 
    
         
            +
                <% } else { %>
         
     | 
| 
      
 31 
     | 
    
         
            +
                <script src="//unpkg.com/react@17.0.2/umd/react.development.js"></script>
         
     | 
| 
      
 32 
     | 
    
         
            +
                <script src="//unpkg.com/react-dom@17.0.2/umd/react-dom.development.js"></script>
         
     | 
| 
      
 33 
     | 
    
         
            +
                <% } %>
         
     | 
| 
      
 34 
     | 
    
         
            +
              </body>
         
     | 
| 
      
 35 
     | 
    
         
            +
            </html>
         
     |