UNPKG

1.27 kBJavaScriptView Raw
1'use strict';
2
3/**
4 * Created by chkui on 2017/6/21.
5 */
6require('babel-polyfill');
7
8// Node babel source map support
9require('source-map-support').install();
10
11// Javascript require hook
12require('babel-register')({
13 presets: ['es2015', 'react', 'stage-0'],
14 plugins: ['add-module-exports']
15});
16
17// Css require hook
18require('css-modules-require-hook')({
19 extensions: ['.scss'],
20 preprocessCss: function preprocessCss(data, filename) {
21 return require('node-sass').renderSync({
22 data: data,
23 file: filename
24 }).css;
25 },
26 camelCase: true,
27 generateScopedName: '[name]-[local]'
28});
29
30// Image require hook
31require('asset-require-hook')({
32 name: '/[hash].[ext]',
33 extensions: ['jpg', 'png', 'gif', 'svg'],
34 limit: 25000
35});
36
37var init = require('./lib/common/init'),
38 log = require('./lib/common/log');
39
40/**
41 * 本地开发服务器入口
42 * 1)必须设置 app。
43 * 2)必须设置 routes。
44 * @param {object} options {
45 * //options的配置详见 {./config/context}
46 * }
47 */
48var devServer = function devServer(options) {
49 log("init server!");
50 //初始化环境参数
51 init(options);
52 //加载服务器运行
53 require('./lib/dev/server');
54};
55
56module.exports = devServer;
\No newline at end of file