Skip to content

Commit 3bb7723

Browse files
committed
优化打包
1 parent 452d049 commit 3bb7723

File tree

5 files changed

+91
-10
lines changed

5 files changed

+91
-10
lines changed

build/pack.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ program
1313
console.log(key + "值输入有误,可选值为leaflet或ol3");
1414
return;
1515
}
16+
1617
var modulePaths = "";
17-
if (key === "core" && modules === "Core") {
18+
if (key === "core") {
1819
modulePaths = getCoreModulePaths();
1920
shell.exec('npm run deploy ' + modulePaths);
2021
return;
@@ -38,7 +39,7 @@ program
3839
}
3940
}
4041
}
41-
shell.exec('npm run deploy ' + modulePaths);
42+
shell.exec('npm run deploy-'+key+' ' + modulePaths);
4243
return;
4344
}
4445
if (modules.indexOf("Core") !== -1) {

package.json

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,39 @@
99
},
1010
"scripts": {
1111
"deploy": "webpack",
12+
"deploy-leaflet": "webpack --config webpack.config.leaflet.js ",
13+
"deploy-ol3": "webpack --config webpack.config.ol3.js ",
14+
"compress": "webpack -p",
1215
"package": "node ./build/pack.js"
1316
},
1417
"keywords": [
1518
"SuperMap",
1619
"leaflet",
17-
"Openlayers"
20+
"Openlayers3"
1821
],
1922
"author": "SuperMap",
2023
"license": "Apache-2.0",
2124
"devDependencies": {
22-
"webpack": "^1.14.0",
2325
"commander": "2.9.0",
26+
"commonjs": "0.0.1",
27+
"jasmine-core": "^2.5.2",
28+
"jquery": "^3.1.1",
29+
"karma": "^1.4.1",
30+
"karma-chrome-launcher": "^2.0.0",
31+
"karma-cli": "^1.0.1",
32+
"karma-commonjs": "^1.0.0",
33+
"karma-coverage": "^1.1.1",
34+
"karma-jasmine": "^1.1.0",
35+
"karma-jasmine-html-reporter": "^0.2.2",
36+
"karma-teamcity-reporter": "^1.0.0",
2437
"shelljs": "0.7.6",
25-
"css-loader": "^0.23.1",
26-
"style-loader": "^0.13.1",
27-
"url-loader": "^0.5.7",
28-
"file-loader":"0.10.0",
29-
"extract-text-webpack-plugin": "^1.0.1"
38+
"underscore": "^1.8.3",
39+
"webpack": "^1.14.0",
40+
"extract-text-webpack-plugin":"^1.0.1",
41+
"file-loader":"^0.10.0",
42+
"style-loader":"^0.13.1",
43+
"css-loader":"^0.26.1",
44+
"imports-loader":"^0.7.0"
3045
},
3146
"dependencies": {
3247
"openlayers": "4.0.0",

webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ module.exports = {
2020
//加载器配置
2121
loaders: [
2222
// {test: /\.css$/, loader: 'style-loader!css-loader'},
23-
{test: /\.css$/, loader: ExtractTextPlugin.extract("style", "css")},
23+
{test: /\.css$/, loader: ExtractTextPlugin.extract("style-loader", "css-loader")},
2424
{test: /\.(png|jpg)$/, loader: "file-loader?name=images/[name].[ext]"}
2525
]
2626
},

webpack.config.leaflet.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
var webpack = require('webpack');
2+
var ExtractTextPlugin = require("extract-text-webpack-plugin");
3+
module.exports = {
4+
5+
6+
//页面入口文件配置
7+
entry: {},
8+
//入口文件输出配置
9+
output: {
10+
path: './dist/',
11+
filename: 'SuperMapiClient9 for Leaflet.js'
12+
},
13+
14+
//其它解决方案配置
15+
resolve: {
16+
extensions: ['', '.js', '.json', '.css']
17+
},
18+
19+
module: {
20+
//加载器配置
21+
loaders: [
22+
// {test: /\.css$/, loader: 'style-loader!css-loader'},
23+
{test: /\.css$/, loader: ExtractTextPlugin.extract("style-loader", "css-loader")},
24+
{test: /\.(png|jpg)$/, loader: "file-loader?name=images/[name].[ext]"}
25+
]
26+
},
27+
28+
//插件项
29+
plugins: [
30+
new ExtractTextPlugin("SuperMapiClient9 for Leaflet.css")
31+
]
32+
};

webpack.config.ol3.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
var webpack = require('webpack');
2+
var ExtractTextPlugin = require("extract-text-webpack-plugin");
3+
module.exports = {
4+
5+
6+
//页面入口文件配置
7+
entry: {},
8+
//入口文件输出配置
9+
output: {
10+
path: './dist/',
11+
filename: 'SuperMapiClient9 for OL3.js'
12+
},
13+
14+
//其它解决方案配置
15+
resolve: {
16+
extensions: ['', '.js', '.json', '.css']
17+
},
18+
19+
module: {
20+
//加载器配置
21+
loaders: [
22+
// {test: /\.css$/, loader: 'style-loader!css-loader'},
23+
{test: /\.css$/, loader: ExtractTextPlugin.extract("style-loader", "css-loader")},
24+
{test: /\.(png|jpg)$/, loader: "file-loader?name=images/[name].[ext]"}
25+
],
26+
noParse: '/node_modules/openlayers/dist/ol.js'
27+
},
28+
29+
//插件项
30+
plugins: [
31+
new ExtractTextPlugin("SuperMapiClient9 for OL3.css")
32+
]
33+
};

0 commit comments

Comments
 (0)