Refactor webpack config code

This commit is contained in:
Tyler Long
2017-04-22 17:12:12 +08:00
parent 7bb988c48b
commit 391149dbd8
4 changed files with 38 additions and 39 deletions

View File

@@ -26,10 +26,10 @@
"test": "yarn run tape && yarn run karma",
"live": "live-server ./test/examples",
"jison": "gulp jison_legacy",
"old_watch": "source ./scripts/watch.sh",
"live_server": "gulp live-server",
"doc": "rm -r build;rm -r dist/www;gulp vartree;cp dist/www/all.html ../mermaid-pages/index.html;cp dist/mermaid.js ../mermaid-pages/javascripts/lib;cp dist/mermaid.forest.css ../mermaid-pages/stylesheets",
"pretest": "yarn jison && yarn lint",
"prepublish": "yarn build && yarn dist && yarn test"
"pretest": "yarn lint",
"prepublishOnly": "yarn build && yarn dist && yarn test"
},
"repository": {
"type": "git",
@@ -61,7 +61,7 @@
"devDependencies": {
"async": "^2.3.0",
"babel-core": "^6.24.1",
"babel-loader": "^6.4.1",
"babel-loader": "^7.0.0",
"babel-plugin-transform-remove-strict-mode": "^0.0.2",
"babel-preset-env": "^1.4.0",
"clone": "^2.1.1",

View File

@@ -1,13 +1,13 @@
import { webConfig, nodeConfig, lessConfig } from './webpack.config.base.js'
const config1 = webConfig()
const config = webConfig()
const config2 = webConfig()
config2.externals = ['fs', 'd3']
config2.output.filename = '[name].slim.js'
const slimConfig = webConfig()
slimConfig.externals = ['fs', 'd3']
slimConfig.output.filename = '[name].slim.js'
const config3 = nodeConfig()
const apiConfig = nodeConfig()
const config4 = lessConfig()
const cssConfig = lessConfig()
export default [config1, config2, config3, config4]
export default [config, slimConfig, apiConfig, cssConfig]

View File

@@ -1,18 +1,18 @@
import ExtractTextPlugin from 'extract-text-webpack-plugin'
import { webConfig, nodeConfig, lessConfig } from './webpack.config.base.js'
const config1 = webConfig()
config1.output.filename = '[name].min.js'
const minConfig = webConfig()
minConfig.output.filename = '[name].min.js'
const config2 = webConfig()
config2.externals = ['fs', 'd3']
config2.output.filename = '[name].slim.min.js'
const slimMinConfig = webConfig()
slimMinConfig.externals = ['fs', 'd3']
slimMinConfig.output.filename = '[name].slim.min.js'
const config3 = nodeConfig()
config3.output.filename = '[name].min.js'
const apiMinConfig = nodeConfig()
apiMinConfig.output.filename = '[name].min.js'
const config4 = lessConfig()
config4.output.filename = '[name].min.css'
config4.plugins = [ new ExtractTextPlugin('[name].min.css') ]
const cssMinConfig = lessConfig()
cssMinConfig.output.filename = '[name].min.css'
cssMinConfig.plugins = [ new ExtractTextPlugin('[name].min.css') ]
export default [config1, config2, config3, config4]
export default [minConfig, slimMinConfig, apiMinConfig, cssMinConfig]

View File

@@ -189,11 +189,11 @@ archy@^1.0.0, archy@~1.0.0:
resolved "https://registry.yarnpkg.com/archy/-/archy-1.0.0.tgz#f9c8c13757cc1dd7bc379ac77b2c62a5c2868c40"
are-we-there-yet@~1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/are-we-there-yet/-/are-we-there-yet-1.1.2.tgz#80e470e95a084794fe1899262c5667c6e88de1b3"
version "1.1.4"
resolved "https://registry.yarnpkg.com/are-we-there-yet/-/are-we-there-yet-1.1.4.tgz#bb5dca382bb94f05e15194373d16fd3ba1ca110d"
dependencies:
delegates "^1.0.0"
readable-stream "^2.0.0 || ^1.1.13"
readable-stream "^2.0.6"
argparse@^1.0.7:
version "1.0.9"
@@ -533,14 +533,13 @@ babel-helpers@^6.24.1:
babel-runtime "^6.22.0"
babel-template "^6.24.1"
babel-loader@^6.4.1:
version "6.4.1"
resolved "https://registry.yarnpkg.com/babel-loader/-/babel-loader-6.4.1.tgz#0b34112d5b0748a8dcdbf51acf6f9bd42d50b8ca"
babel-loader@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/babel-loader/-/babel-loader-7.0.0.tgz#2e43a66bee1fff4470533d0402c8a4532fafbaf7"
dependencies:
find-cache-dir "^0.1.1"
loader-utils "^0.2.16"
loader-utils "^1.0.2"
mkdirp "^0.5.1"
object-assign "^4.0.1"
babel-messages@^6.23.0:
version "6.23.0"
@@ -1395,8 +1394,8 @@ caniuse-api@^1.5.2:
lodash.uniq "^4.5.0"
caniuse-db@^1.0.30000529, caniuse-db@^1.0.30000634, caniuse-db@^1.0.30000639:
version "1.0.30000656"
resolved "https://registry.yarnpkg.com/caniuse-db/-/caniuse-db-1.0.30000656.tgz#127c8c6e655e7464e58f039558f1e878fcca3c45"
version "1.0.30000657"
resolved "https://registry.yarnpkg.com/caniuse-db/-/caniuse-db-1.0.30000657.tgz#8192aec745019cc050217ad049c60dad21e3d1bc"
capture-stack-trace@^1.0.0:
version "1.0.0"
@@ -2294,8 +2293,8 @@ ee-first@1.1.1:
resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d"
electron-to-chromium@^1.2.7:
version "1.3.5"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.5.tgz#6cd6ff2106224a6130e235f21050f9546bc3e729"
version "1.3.7"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.7.tgz#9fb75a2417f28114425d364de118d1cfd681432b"
elliptic@^6.0.0:
version "6.4.0"
@@ -2641,8 +2640,8 @@ esnext-async@^0.0.9:
zen-observable "^0.3.0"
espree@^3.4.0:
version "3.4.1"
resolved "https://registry.yarnpkg.com/espree/-/espree-3.4.1.tgz#28a83ab4aaed71ed8fe0f5efe61b76a05c13c4d2"
version "3.4.2"
resolved "https://registry.yarnpkg.com/espree/-/espree-3.4.2.tgz#38dbdedbedc95b8961a1fbf04734a8f6a9c8c592"
dependencies:
acorn "^5.0.1"
acorn-jsx "^3.0.0"
@@ -3219,8 +3218,8 @@ gauge@~2.6.0:
wide-align "^1.1.0"
gauge@~2.7.1:
version "2.7.3"
resolved "https://registry.yarnpkg.com/gauge/-/gauge-2.7.3.tgz#1c23855f962f17b3ad3d0dc7443f304542edfe09"
version "2.7.4"
resolved "https://registry.yarnpkg.com/gauge/-/gauge-2.7.4.tgz#2c03405c7538c39d7eb37b317022e325fb018bf7"
dependencies:
aproba "^1.0.3"
console-control-strings "^1.0.0"
@@ -6713,7 +6712,7 @@ read@1, read@~1.0.1, read@~1.0.7:
dependencies:
mute-stream "~0.0.4"
"readable-stream@1 || 2", readable-stream@^2.0.0, "readable-stream@^2.0.0 || ^1.1.13", readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.0.3, readable-stream@^2.0.5, readable-stream@^2.1.4, readable-stream@^2.1.5, readable-stream@^2.2.2, readable-stream@^2.2.6:
"readable-stream@1 || 2", readable-stream@^2.0.0, readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.0.3, readable-stream@^2.0.5, readable-stream@^2.0.6, readable-stream@^2.1.4, readable-stream@^2.1.5, readable-stream@^2.2.2, readable-stream@^2.2.6:
version "2.2.9"
resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.2.9.tgz#cf78ec6f4a6d1eb43d26488cac97f042e74b7fc8"
dependencies: