forked from fegos/fego-editor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
73 lines (72 loc) · 1.56 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
71
72
73
'use strict'
const path = require('path')
const webpack = require('webpack')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
const ROOT_PATH = path.resolve(__dirname, './')
const SRC_PATH = path.resolve(ROOT_PATH, 'src')
module.exports = {
context: ROOT_PATH,
resolve: {
modules: ['node_modules'],
alias: {
'iconfont': path.resolve(SRC_PATH, 'iconfont'),
'utils': path.resolve(SRC_PATH, 'utils')
},
extensions: ['.js', '.jsx']
},
entry: {
index: './src/index.js',
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].js',
libraryTarget: 'commonjs2'
},
externals: {
"draft-convert": "draft-convert",
'draft-js': 'draft-js',
'react': 'react',
'react-dom': 'react-dom',
'immutable': 'immutable'
},
module: {
rules: [{
test: /\.jsx?$/,
loader: 'babel-loader',
include: [SRC_PATH]
}, {
test: /\.css$/,
use: ['style-loader', 'postcss-loader']
}, {
test: /\.less$/,
exclude: [
path.resolve(ROOT_PATH, 'node_modules')
],
use: ExtractTextPlugin.extract({
fallback: {
loader: 'style-loader'
},
use: [{
loader: 'css-loader',
options: {
modules: true,
localIdentName: '[local]',
minimize: true
}
}, 'postcss-loader', 'less-loader']
})
}]
},
plugins: [
new ExtractTextPlugin('editor.css'),
new webpack.optimize.UglifyJsPlugin({
compress: {
unused: true,
dead_code: true,
warnings: false
}
}),
new BundleAnalyzerPlugin
]
}