當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript webpack.default函數代碼示例

本文整理匯總了TypeScript中webpack.default函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript default函數的具體用法?TypeScript default怎麽用?TypeScript default使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了default函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: dev

function dev(name: string, callback: () => void) {
  //var filename = name.split('/')[1].substr(0, 3) + '-' + name.split('/')[1].substr(3) + '.js'
  var filename = _.kebabCase(name.split('/')[1]) + '.js'
  var options: any = {
    entry: './' + name + '.js',
    output: {
      path: path.join(__dirname, '../../../public/assets/js'),
      publicPath: "/assets/",
      filename: "bundle.js"
    },
    resolve: {
      extensions: ['', '.webpack.js', '.web.js', '.js']
    },
    module: {
      loaders: [
        { test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader' },
        { test: /\.less$/, exclude: /node_modules/, loader: 'style!css!less' }
      ]
    },
    devtool: "sourcemap",
    debug: true
  }
  var port = 7070

  var compiler = webpack(options)
  return new WebpackDevServer(compiler, {
    stats: {
      colors: true
    },
    historyApiFallback: true
  }).listen(port, "localhost", function(err) {
    if (err) throw err
    callback()
  })
}
開發者ID:starlying,項目名稱:projs,代碼行數:35,代碼來源:pack.ts

示例2: webpackDevServer

export async function webpackDevServer(): Promise<void> {
    const compiler = createWebpackCompiler(webpackConfig)
    const server = new WebpackDevServer(compiler as any, {
        publicPath: '/.assets/',
        contentBase: './ui/assets',
        stats: WEBPACK_STATS_OPTIONS,
        noInfo: false,
        proxy: {
            '/': {
                target: 'http://localhost:3081',
                ws: true,
                // Avoid crashing on "read ECONNRESET".
                onError: err => console.error(err),
                onProxyReqWs: (_proxyReq, _req, socket) =>
                    socket.on('error', err => console.error('WebSocket proxy error:', err)),
            },
        },
    })
    return new Promise<void>((resolve, reject) => {
        server.listen(3080, '127.0.0.1', (err?: Error) => {
            if (err) {
                reject(err)
            } else {
                resolve()
            }
        })
    })
}
開發者ID:JoYiRis,項目名稱:sourcegraph,代碼行數:28,代碼來源:gulpfile.ts

示例3: Promise

  run: function(runTaskOptions: ServeTaskOptions) {

    var project = this.cliProject;

    rimraf.sync(path.resolve(project.root, runTaskOptions.outputPath));

    const config = new NgCliWebpackConfig(project, runTaskOptions.environment).config;
    const webpackCompiler = webpack(config);

    webpackCompiler.apply(new ProgressPlugin({
      profile: true
    }));

    return new Promise( (resolve, reject) => {
      webpackCompiler.watch({}, (err, stats) => {
        if (err) {
          lastHash = null;
          console.error(err.stack || err);
          if(err.details) console.error(err.details);
            reject(err.details);
        }

        if(stats.hash !== lastHash) {
          lastHash = stats.hash;
          process.stdout.write(stats.toString(webpackOutputOptions) + "\n");
        }
      })
    })
  }
開發者ID:TheLarkInn,項目名稱:angular-cli,代碼行數:29,代碼來源:build-webpack-watch.ts

示例4: Promise

    it('bundleable by webpack with no errors', async function() {
        this.timeout(50000);
        const memoryFS = new MemoryFS();
        const rootPath = await pkgDir(__dirname);

        const compiler = webpack({
            mode: 'development',
            entry: {
                main: path.join(rootPath!, 'dist', 'src', 'lib', 'service.js')
            },
            node: {
                path: 'empty', // users should provide alias to path-webpack
                net: 'empty',
                fs: 'empty',
                module: 'empty'
            }
        });

        compiler.outputFileSystem = memoryFS;

        await new Promise((res, rej) =>
            compiler.run((err, stats) => {
                if (err || stats.hasErrors()) {
                    rej(err || new Error(stats.toString()));
                } else {
                    res();
                }
            })
        );
    });
開發者ID:wix,項目名稱:stylable-intelligence,代碼行數:30,代碼來源:browser-compatible.spec.ts

示例5: compiler

 private compiler(): Property<webpack.Compiler, Error> {
   try {
     return Kefir.constant(webpack(this.config));
   } catch (e) {
     return Kefir.constantError(e);
   }
 }
開發者ID:valtech-nyc,項目名稱:brookjs,代碼行數:7,代碼來源:webpack.ts

示例6: Promise

  run: function(runTaskOptions: ServeTaskOptions) {

    var project = this.cliProject;

    rimraf.sync(path.resolve(project.root, runTaskOptions.outputPath));
    var config = new NgCliWebpackConfig(project, runTaskOptions.environment).config;
    const webpackCompiler = webpack(config);

    const ProgressPlugin  = require('webpack/lib/ProgressPlugin');

    webpackCompiler.apply(new ProgressPlugin({
      profile: true
    }));

    return new Promise((resolve, reject) => {
      webpackCompiler.run((err, stats) => {
        // Don't keep cache
        // TODO: Make conditional if using --watch
        webpackCompiler.purgeInputFileSystem();

        if(err) {
          lastHash = null;
          console.error(err.stack || err);
          if(err.details) console.error(err.details);
            reject(err.details);
        }

        if(stats.hash !== lastHash) {
          lastHash = stats.hash;
          process.stdout.write(stats.toString(webpackOutputOptions) + "\n");
        }
        resolve();
      });
    });
  }
開發者ID:TheLarkInn,項目名稱:angular-cli,代碼行數:35,代碼來源:build-webpack.ts

示例7: webpack

export const bundle = (entry: any, output: string, tsconfig?: string, outputDir?: string, watch?: boolean, minify?: boolean, callback?: any) => {
  const webpackConfig = Object.assign<{[index: string]: any}, typeof config>({}, config)
  const plugins = []
  if (minify) {
    plugins.push(new webpack.optimize.UglifyJsPlugin({
      mangle: {
        except: ['$super', '$', 'exports', 'require']
      },
      compress: {
        warnings: false
      }
    }))
    delete webpackConfig.devtool
  }
  if (tsconfig) {
    webpackConfig.ts.configFileName = tsconfig
  }
  webpackConfig.entry = entry
  webpackConfig.plugins = plugins
  webpackConfig.output.path = path.join(process.cwd(), outputDir || 'dist')
  webpackConfig.output.filename = output
  webpackConfig.watch = watch
  return webpack(webpackConfig, (err, stats) => {
    if (err) {
      throw new gutil.PluginError('webpack', err)
    }
    gutil.log('[webpack]', stats.toString())
    callback()
  })
}
開發者ID:rucky2013,項目名稱:teambition-sdk,代碼行數:30,代碼來源:bundle.ts

示例8: startPublications

export function startPublications() {
  const mode = process.env.NODE_ENV || "DEVELOPMENT";
  const app = express();

  if (mode.toUpperCase() === "DEVELOPMENT") {
    const compiler = webpack(webpackConfig as webpack.Configuration);
    app.use(
      webpackDevMiddleware(compiler, {
        publicPath: webpackConfig.output.publicPath,
      })
    );
    app.use(webpackHotMiddleware(compiler));
    app.use("/playground", graphqlPlayground({ endpoint: "/graphql" }));
  } else {
    const publicPath = path.resolve(__dirname, "../public");
    app.use(express.static(publicPath));
    app.get("*", (req, res) =>
      res.sendFile(path.resolve(publicPath, "index.html"))
    );
  }

  app.use(jwt(jwtConfig));
  app.use(
    "/graphql",
    graphqlHttp(request => ({
      schema,
      context: { user: request.user },
    }))
  );
  app.use(onAuthError);
  app.get("/documents/:id/pdf", documentPdfHandler);
  app.listen(PORT, () => {
    console.log(`Publications started on port ${PORT}.`);
  });
}
開發者ID:carlospaelinck,項目名稱:publications-js,代碼行數:35,代碼來源:index.ts

示例9: Promise

export function build<T>(config: T) {
  const compiler = webpack(config)
  return new Promise((resolve, reject) => {
    compiler.run((err, stats) => {
      if (err) {
        return reject(err)
      }

      const messages = formatWebpackMessages(stats.toJson())
      if (messages.errors.length) {
        // Only keep the first error. Others are often indicative
        // of the same problem, but confuse the reader with noise.
        if (messages.errors.length > 1) {
          messages.errors.length = 1
        }
        return reject(new Error(messages.errors.join('\n\n')))
      }

      return resolve({
        stats,
        warnings: messages.warnings,
      })
    })
  })
}
開發者ID:aranja,項目名稱:tux,代碼行數:25,代碼來源:webpack.ts

示例10: WebpackDevServer

export = () => {

  let options = {
    contentBase: 'dist/dev',
    colors: true,
    progress: true,
    watch: true,
    stats: {
      colors: true,
      progress: true
    }
  };

  new WebpackDevServer(webpack(config), options)
    .listen(
      config.devServer.port,
      config.devServer.host,
      (err: any) => {
        if(err) throw new gutil.PluginError("webpack-dev-server", err);
        // Server listening
        gutil.log(
          "[webpack-dev-server]",
          "http://" + config.devServer.host + ":" + config.devServer.port + "/webpack-dev-server/index.html");

        // keep the server alive or continue?
        // callback();

      });

};
開發者ID:mapkiwiz,項目名稱:sectorisation,代碼行數:30,代碼來源:webpack.server.dev.ts


注:本文中的webpack.default函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。