-
Notifications
You must be signed in to change notification settings - Fork 11
/
cooking.conf.js
159 lines (142 loc) · 4.41 KB
/
cooking.conf.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
/**
* =============================================================================
* Cooking Config
* =============================================================================
*
* @see http://cookingjs.github.io/zh-cn/configuration.html
* @see https://webpack.js.org/configuration/
* @permission Engineer
*
* @author dondevi
* @create 2018-02-02
*
* @todo 2018-03-29 dondevi
* 1.Split stylus code
*
* @update 2018-03-13 dondevi
* @update 2018-03-21 dondevi
* 1.Add: Babel for Quasar !
* @update 2018-03-22 dondevi
* 1.Update: Chunk config !
* @update 2018-03-23 dondevi
* 1.Add: build/quasar.js !
* @update 2018-04-02 dondevi
* 1.Add: devServer.compress: true
*/
const fs = require("fs");
const path = require("path");
const cooking = require("cooking");
const webpack = require("webpack");
const isDev = "development" === process.env.NODE_ENV;
let cookingConfig = {
entry: {
app: "src/main.js",
mock: "mock/index.js",
},
chunk: [
{ name: "vue", chunks: ["app"],
minChunks: module => /node_modules[\/\\]vue/.test(module.context),
},
{ name: "quasar", chunks: ["app"],
minChunks: module => /node_modules[\/\\]quasar/.test(module.context),
},
{ name: "echarts", chunks: ["app"],
minChunks: module => /node_modules[\/\\]echarts/.test(module.context),
},
{ name: "manifest", minChunks: Infinity },
],
template: {
"index.html": {
template: "src/index.html", chunksSortMode: "manual",
chunks: ["manifest", "vue", "quasar", "echarts", "mock", "app"],
},
},
dist: "dist",
publicPath: "./",
assetsPath: "./",
hash: true,
clean: true,
postcss: [],
/**
* For stylus, you need to add below to {user_home}/.cooking/package.json:
* devDependencies: {
* "stylus": "^0.54.5",
* "stylus-loader": "^3.0.1",
* ...
* }
*/
extends: ["vue2", "stylus", "autoprefixer"],
minimize: true,
// sourceMap: "cheap-module-eval-source-map",
sourceMap: isDev ? "source-map" : false,
extractCSS: true,
alias: {
"src": path.resolve(__dirname, "src"),
"mock": path.resolve(__dirname, "mock"),
"config": path.resolve(__dirname, "src/config"),
"router": path.resolve(__dirname, "src/router"),
"service": path.resolve(__dirname, "src/service"),
"pages": path.resolve(__dirname, "src/pages"),
"frames": path.resolve(__dirname, "src/frames"),
"assets": path.resolve(__dirname, "src/assets"),
"filters": path.resolve(__dirname, "src/filters"),
"modules": path.resolve(__dirname, "src/modules"),
"components": path.resolve(__dirname, "src/components"),
},
devServer: {
port: 8101,
hostname: "0.0.0.0",
publicPath: "/",
contentBase: "dist",
clean: false,
compress: true,
extractCSS: false,
proxy: {
"/monitorcenter-as-server/monitor/websocket/**": {
changeOrigin: true,
target: "ws://192.168.0.157:8900", // Development
// target: "ws://crj.xfbm100.com", // Production
ws: true,
},
},
},
};
cooking.set(cookingConfig);
cooking.add("loader.html", {
test: /\.html$/, loader: "html-loader",
options: { attrs: ["img:src", "link:href"] },
});
cooking.add("loader.mp3", {
test: /\.mp3$/, loader: "url-loader",
options: { limit: 1000, name: "[name].[hash:7].[ext]" },
});
// Config For Quasar
const quasarTheme = "mat" || "ios";
const quasarFilepath = require("./build/quasar.js")(quasarTheme);
cooking.add("resolve.alias[quasar-framework-custom]", quasarFilepath);
cooking.add("resolve.extensions", [".js", ".vue", `.${quasarTheme}.js`, `.${quasarTheme}.vue`]);
cooking.add("plugin.DefineQuasar", new webpack.DefinePlugin({ "__THEME__": JSON.stringify(quasarTheme) }));
// Babel for Quasar
!isDev && cooking.add("loader.js", {
test: /\.(jsx?|babel|es6)$/,
include: [
path.resolve(__dirname, "src"),
path.resolve(__dirname, "mock"),
// path.resolve(__dirname, "node_modules/quasar-framework"), // Problem with "npm link"
fs.realpathSync("node_modules/quasar-framework"),
],
use: {
loader: "babel-loader",
/**
* If not set this, ".babelrc" will be searched on resovle path,
* and faied in "node_modules/quasar-framework".
* @see http://babeljs.io/docs/usage/babelrc/#lookup-behavior
*/
options: {
babelrc: false,
extends: path.resolve(__dirname, ".babelrc"),
},
},
});
let webpackConfig = cooking.resolve();
module.exports = webpackConfig;