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