1 | var webpack = require("webpack")
|
2 | var path = require("path")
|
3 | var HtmlWebpackPlugin = require('html-webpack-plugin')
|
4 | var CopyWebpackPlugin = require('copy-webpack-plugin')
|
5 | var ExtractTextPlugin = require("extract-text-webpack-plugin")
|
6 |
|
7 | const es3ifyWebpackPlugin = require('es3ify-webpack-plugin-v2')
|
8 | const LodashModuleReplacementPlugin = require('lodash-webpack-plugin')
|
9 |
|
10 | const merge = require('webpack-merge')
|
11 | var env = process.env.NODE_ENV
|
12 | var plugins = []
|
13 |
|
14 | var projectRootPath = path.resolve(__dirname, './')
|
15 |
|
16 | plugins.push(new webpack.DefinePlugin({
|
17 | "process.env.NODE_ENV": JSON.stringify(env)
|
18 | }))
|
19 | plugins.push(new webpack.optimize.ModuleConcatenationPlugin())
|
20 | plugins.push(new webpack.ExtendedAPIPlugin())
|
21 | plugins.push(new webpack.DllReferencePlugin({
|
22 | context: __dirname,
|
23 | manifest: merge(require('./vendor/shim.manifest.json'), require('./vendor/vendor.manifest.json')),
|
24 | }))
|
25 |
|
26 | plugins.push(new es3ifyWebpackPlugin())
|
27 | plugins.push(new HtmlWebpackPlugin({
|
28 | title: '云ERP',
|
29 | favicon: './assets/img/favicon.ico',
|
30 | filename: 'index.html',
|
31 | template: 'index.html',
|
32 | chunks: ['edf', 'bundle', 'icon', 'greenTheme'],
|
33 | hash: false,
|
34 | inject: 'body',
|
35 | minify: {
|
36 | removeComments: true,
|
37 | collapseWhitespace: true,
|
38 | removeAttributeQuotes: true
|
39 | }
|
40 | }))
|
41 |
|
42 | plugins.push(new ExtractTextPlugin('[name].[hash:8].css'))
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 | plugins.push(new CopyWebpackPlugin([{
|
54 | from: './robots.txt',
|
55 | to: 'robots.txt',
|
56 | toType: 'file'
|
57 | }]))
|
58 |
|
59 |
|
60 | plugins.push(new LodashModuleReplacementPlugin)
|
61 |
|
62 | plugins.push(new webpack.optimize.CommonsChunkPlugin({
|
63 | names: ['edf'],
|
64 | filename: '[name].[hash:8].min.js',
|
65 | minChunks: Infinity
|
66 | }))
|
67 |
|
68 | plugins.push(new CopyWebpackPlugin([{
|
69 | from: './vendor',
|
70 | to: './vendor',
|
71 | ignore: ['.*']
|
72 | }]))
|
73 |
|
74 | module.exports = {
|
75 | devtool: 'cheap-module-eval-source-map',
|
76 | entry: {
|
77 | bundle: "./index.js",
|
78 | edf: ["edf-app-loader", "edf-meta-engine", "edf-component", "edf-consts", "edf-utils", "webapi"],
|
79 | businessBlueTheme: "./assets/styles/businessBlue.less",
|
80 | blackTheme: "./assets/styles/black.less",
|
81 | greenTheme: "./assets/styles/green.less",
|
82 | orangeTheme: "./assets/styles/orange.less",
|
83 | blueTheme: "./assets/styles/blue.less",
|
84 | yellowTheme: "./assets/styles/yellow.less",
|
85 | icon: "./component/assets/style/iconset.less",
|
86 |
|
87 | },
|
88 |
|
89 | output: {
|
90 | path: path.join(__dirname, "/dist/"),
|
91 | filename: '[name].[hash:8].min.js',
|
92 | chunkFilename: '[name].[hash:8].chunk.js'
|
93 | },
|
94 |
|
95 | resolve: {
|
96 | extensions: [".js"],
|
97 | alias: {
|
98 | 'edf-app-loader': path.resolve(projectRootPath, './app-loader/index.js'),
|
99 | 'edf-meta-engine': path.resolve(projectRootPath, './meta-engine/index.js'),
|
100 | 'edf-component': path.resolve(projectRootPath, './component/index.js'),
|
101 | 'edf-utils': path.resolve(projectRootPath, './utils/index.js'),
|
102 | 'webapi': path.resolve(projectRootPath, './api/index.js'),
|
103 | 'edf-consts': path.resolve(projectRootPath, './constant/consts.js'),
|
104 | 'eharts': path.resolve(projectRootPath, './vendor/echarts.min.js'),
|
105 | 'zrender': path.resolve(projectRootPath, './vendor/zrender.min.js')
|
106 | }
|
107 | },
|
108 | externals: {
|
109 | "echarts": 'echarts',
|
110 | "zrender": 'zrender',
|
111 | },
|
112 | module: {
|
113 | rules: [{
|
114 | test: /\.(css|less)/,
|
115 | use: ExtractTextPlugin.extract({
|
116 | fallback: 'style-loader',
|
117 | use: ['css-loader', 'less-loader']
|
118 | })
|
119 | }, {
|
120 | test: /\.js?$/,
|
121 | exclude: /node_modules/,
|
122 | use: [{
|
123 | loader: 'babel-loader',
|
124 | options: {
|
125 | cacheDirectory: true
|
126 | }
|
127 | }]
|
128 | }, {
|
129 | test: /\.(eot|woff|woff2|ttf|svg|png|jpe?g|gif|mp4|webm)(\?\S*)?$/,
|
130 | use: {
|
131 | loader: 'url-loader',
|
132 | options: {
|
133 | name: '[name].[hash:8].[ext]',
|
134 | limit: 8192
|
135 | }
|
136 | }
|
137 | }],
|
138 | },
|
139 | devServer: {
|
140 | contentBase: './dist/',
|
141 | proxy: {
|
142 |
|
143 | }
|
144 | },
|
145 | plugins: plugins
|
146 | }
|