forked from steamerjs/steamer-react
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwebpack.node.js
executable file
·126 lines (120 loc) · 4.42 KB
/
webpack.node.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
'use strict';
// require("babel-register")({
// ignore: /node_modules/,
// optional: ["es7.objectRestSpread", "runtime"]
// });
const path = require('path'),
webpack = require('webpack');
var config = require('./config/config'),
nodeModulesPath = path.join(__dirname, 'node_modules'),
parentNodeModulePath = path.join(path.dirname(__dirname), 'node_modules');
/**
* [nodeConfig config for backend]
* @type {Object}
*/
var nodeConfig = {
entry: {
index: [path.join(config.path.node, "/asset/index.js")],
detail: [path.join(config.path.node, "/asset/detail.js")],
comment: [path.join(config.path.node, "/asset/comment.js")],
},
output: {
publicPath: config.defaultPath,
path: path.join(config.path.pub),
filename: "node/[name].js",
},
target: 'node',
node: {
__filename: true,
__dirname: true
},
module: {
loaders: [
{
test: /\.js?$/,
loader: 'babel',
query: {
cacheDirectory: '/webpack_cache/',
plugins: [
'transform-decorators-legacy',
[
"transform-runtime", {
"polyfill": false,
"regenerator": true
}
]
],
presets: [
'es2015-loose',
'react',
]
},
exclude: /node_modules/,
},
{
test: /\.css$/,
loader: "ignore-loader",
},
// {
// test: /\.less$/,
// loader: "style-loader!css-loader!less-loader",
// include: [parentNodeModulePath, nodeModulesPath, path.resolve(config.path.src)]
// },
{
test: /\.scss$/,
loader: "ignore-loader",
// include: [parentNodeModulePath, nodeModulesPath, path.resolve(config.path.src)]
},
{
test: /\.html$/,
loader: 'html-loader'
},
],
noParse: [
]
},
resolve: {
moduledirectories:['node_modules', config.path.src],
extensions: ["", ".js", ".jsx", ".es6", "css", "scss", "png", "jpg", "jpeg", "ico"],
alias: {
'Root': path.join(config.path.src, '/page/spa/root/Root'),
'routes': path.join(config.path.src, '/page/spa/root/route_server'),
'configureStore': path.join(config.path.src, '/page/spa/stores/configureStore.js'),
'redux': 'redux/dist/redux',
'react-redux': 'react-redux/dist/react-redux',
'classnames': 'classnames',
'utils': path.join(config.path.src, '/js/common/utils'),
'spin': path.join(config.path.src, '/js/common/spin'),
'spinner': path.join(config.path.src, '/page/common/components/spinner/'),
'report': path.join(config.path.src, '/js/common/report'),
'touch': path.join(config.path.src, '/page/common/components/touch/'),
'scroll':path.join(config.path.src, '/page/common/components/scroll/'),
'immutable-pure-render-decorator': path.join(config.path.src, '/js/common/immutable-pure-render-decorator'),
'pure-render-decorator': path.join(config.path.src, '/js/common/pure-render-decorator'),
'requestSync': path.join(config.path.node, '/common/requestSync'),
}
},
plugins: [
new webpack.DefinePlugin({
"process.env": {
NODE_ENV: JSON.stringify(process.env.NODE_ENV)
},
"isNode": true,
"console.dev": (process.env.NODE_ENV === "__NODE_DEV__") ?
function(msg) { console.log(msg); } :
function(msg) {}
}),
new webpack.BannerPlugin("module.exports = ", {entryOnly : true, raw: true}),
// new webpack.optimize.UglifyJsPlugin(
// {
// compress: {
// warnings: false
// }
// }
// )
// new webpack.optimize.OccurrenceOrderPlugin(),
// new webpack.NoErrorsPlugin()
],
watch: true, // watch mode
};
module.exports = nodeConfig;