forked from yedegesong/typescript-webpack-react-antd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.dev.config.js
73 lines (67 loc) · 1.9 KB
/
webpack.dev.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
'use strict';
/**
* Created by x on 11/23/15.
*/
var path = require('path');
/**
* 导入文件入口
* @type {{index: string, details: string}|exports|module.exports}
*/
var webpack = require('webpack');
var filepath = require('./www/filepath');
//提取公用CSS
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var node_modules = path.resolve(__dirname, 'node_modules');
var pathToSrc = path.resolve(__dirname, 'src');
var pathToBuild = path.resolve(__dirname, 'www');
//页面主控制目录
var controllerSrc = path.resolve(__dirname, 'www','ts','controller');
var _entry = function(options){
var entry = {};
for (var name in options) {
entry[name] = controllerSrc+'/'+options[name];
}
return entry;
}
var config = {
pathToBuild: pathToBuild,
devtool: "source-map",
//入口文件配置
entry:_entry(filepath),
resolve: {
extensions: ['', '.js', '.jsx','.ts','.tsx']
},
//输出文件配置
output: {
path: path.resolve(__dirname, 'www/dist'),
chunkFilename: '[name].js',
filename: '[name].js',
publicPath: '/dist/'
},
module: {
loaders: [
{
test: /\.(js|jsx|tsx|ts)?$/,
loaders:['ts-loader'],
//loaders: ['react-hot', 'babel','ts-loader'],
exclude: /node_modules/
},
{
test: /\.css$/,
loader: 'style!css'
}
],
},
preLoaders: [
// All output '.js' files will have any sourcemaps re-processed by 'source-map-loader'.
{ test: /\.js$/, loader: "source-map-loader" }
],
plugins: [
new webpack.optimize.CommonsChunkPlugin({
name: "common",
filename:"common.js"
}),
new webpack.HotModuleReplacementPlugin()
]
};
module.exports = config;