forked from we-demo/nw-chat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
68 lines (64 loc) · 1.92 KB
/
webpack.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
'use strict'
const path = require('path')
const _ = require('lodash')
const webpack = require('webpack')
const WebpackNotifierPlugin = require('webpack-notifier')
const deps = _.keys(require('./package.json').dependencies)
const inlinedDeps = [
'normalize.css',
'react',
'react-dom',
'react-router',
"react-redux",
"redux-form",
]
// const externalDeps = _.without(deps, ...inlinedDeps)
const externalDeps = _.without.apply(null, [deps].concat(inlinedDeps))
module.exports = {
module: {
preLoaders: [
{ test: /\.jsx?$/, include: path.resolve('src'), loader: 'eslint' },
],
loaders: [
{ test: /\.jsx?$/, include: path.resolve('src'), loader: 'babel' },
{ test: /\.css$/, loader: 'style!css' },
{ test: /\.scss$/, loader: 'style!css!sass' },
]
},
target: 'node-webkit',
node: {
__filename: true,
__dirname: true
},
resolve: {
alias: {
// 不用react-lite 影响Editor:focus/blur
// 'react': 'react-lite',
// 'react-dom': 'react-lite',
},
extensions: ['', '.js', '.jsx'],
packageMains: ['webpack', 'browser', 'web', 'browserify', ['jam', 'main'], 'main']
},
// fixme: 这种方式存在问题 比如react/node_modules/fbjs的解析
// 由于是nw/node环境 默认将依赖external
// https://github.com/fritx/os-web/blob/dev/task/webpack.server.js
// externals: [
// (ctx, req, cb) => {
// // if (resolve(ctx, req).indexOf(serverDir) !== 0) return cb()
// if (/^\.\.?\//.test(req)) return cb()
// if (inlinedDeps.indexOf(req) > -1) return cb()
// cb(null, `commonjs ${req}`)
// },
// ],
plugins: [
new WebpackNotifierPlugin({ alwaysNotify: true }),
// new webpack.NoErrorsPlugin(),
new webpack.ExternalsPlugin('commonjs', externalDeps),
new webpack.ProvidePlugin({
Promise: 'bluebird',
}),
// new webpack.DefinePlugin({
// 'rootDir': JSON.stringify(__dirname)
// })
],
};