-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
70 lines (68 loc) · 2.44 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
69
70
/**
* Created by Administrator on 2017/4/12.
*/
var path = require('path');
var webpack = require('webpack');
var CopyWebpackPlugin = require('copy-webpack-plugin');
// var ExtractTextPlugin = require("extract-text-webpack-plugin");
var APP_PATH = path.resolve(__dirname, 'app');
var SRC_PATH = path.resolve(__dirname, 'src');
module.exports = {
target: 'electron',
node: {
fs: 'empty'
},
entry:{
js:'./src/entry.js'
},
output:{
filename:'./app/entry.js',
//chunkFilename:'./app/[chunkhash].js'
},
module:{
loaders:[
{
loader: 'babel-loader',
include: [
SRC_PATH,
],
// Only run `.js` and `.jsx` files through Babel
test: /\.js|\.jsx?$/,
// Options to configure babel with
query: {
presets: ['es2015', 'react'],
"plugins": [
["import", { libraryName: "antd", style: "css" }] // `style: true` 会加载 less 文件
]
}
},
{
test: /\.png|\.jpg$/,
loader:'url-loader'
},
//scss
{
test: /\.scss|\.sass$/,
loaders:['style-loader', 'css-loader', 'sass-loader']
},
{
test: /\.css$/,
loaders: ['style-loader', 'css-loader']
}
]
},
plugins:[
//new ExtractTextPlugin("[name].css", { allChunks: true }),
//new webpack.optimize.CommonsChunkPlugin("chunks"),
//new webpack.optimize.DedupePlugin(),
//new webpack.HotModuleReplacementPlugin(),
new CopyWebpackPlugin([
{ from: path.resolve(SRC_PATH, 'main.js'), to: path.resolve(APP_PATH,'main.js') },
{ from: path.resolve(SRC_PATH, 'icon.icns'), to: path.resolve(APP_PATH,'icon.icns') },
{ from: path.resolve(SRC_PATH, 'index.html'), to: path.resolve(APP_PATH,'index.html') },
{ from: path.resolve(SRC_PATH, '../package.json'), to: path.resolve(APP_PATH,'package.json') },
{ from: path.resolve(SRC_PATH, 'config'), to: path.resolve(APP_PATH,'config') },
{ from: path.resolve(SRC_PATH, 'function'), to: path.resolve(APP_PATH,'function')}
])
]
}