Skip to content

Commit

Permalink
build: remove theme.variables & add variables building script
Browse files Browse the repository at this point in the history
  • Loading branch information
xxyan0205 committed Dec 13, 2018
1 parent a2aff41 commit c45fc11
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 39 deletions.
Empty file.
43 changes: 21 additions & 22 deletions build/rollup/build-mand-mobile.rollup.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,27 @@ const inputOptions = {

function build() {
return rollup.rollup(inputOptions)
.then(bundle => {
return Promise.all([
isSpecial
? bundle.write({
file: path.resolve(LIB_DIR, 'mand-mobile.esm.js'),
format: 'es',
}).then(() => {
console.info('Build ES Module & Variable Css Success')
})
: bundle.write({
file: path.resolve(LIB_DIR, 'mand-mobile.umd.js'),
format: 'umd',
name: 'mand-mobile'
}).then(() => {
console.info('Build UMD Module Success')
})
])
})
.catch(err => {
console.info(err)
console.info('build error')
})
.then(bundle => {
return Promise.all([
bundle.write({
file: path.resolve(LIB_DIR, 'mand-mobile.esm.js'),
format: 'es',
}).then(() => {
console.info('Build ES Module')
}),
bundle.write({
file: path.resolve(LIB_DIR, 'mand-mobile.umd.js'),
format: 'umd',
name: 'mand-mobile'
}).then(() => {
console.info('Build UMD Module Success')
})
])
})
.catch(err => {
console.info(err)
console.info('build error')
})
}

build()
8 changes: 2 additions & 6 deletions build/rollup/rollup-plugin-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const babelrc = require('babelrc-rollup').default
const isProduction = process.env.NODE_ENV === 'production'
const isTest = process.env.NODE_ENV === 'testing'
const isDev = !(isProduction || isTest)
const isSpecial = process.env.BUILD_TYPE === 'special'
// const isSpecial = process.env.BUILD_TYPE === 'special'

function resolve(dir) {
return path.resolve(__dirname, '../..', dir)
Expand All @@ -49,11 +49,7 @@ function vueWarpper() {
distDir = DEV_OUTPUT_DIR
fileName = 'mand-mobile-dev.css'
} else if (isProduction) {
if (isSpecial) {
fileName = 'mand-mobile.variable.css'
} else {
fileName = 'mand-mobile.css'
}
fileName = 'mand-mobile.css'
distDir = LIB_DIR
} else if (isTest) {
distDir = TEST_OUTPUT_DIR
Expand Down
12 changes: 4 additions & 8 deletions build/webpack/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const path = require('path')
const config = require('../../config')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const resolve = file => path.resolve(__dirname, file)
const isProd = process.env.NODE_ENV === 'production'
// const isProd = process.env.NODE_ENV === 'production'

exports.assetsPath = function (_path) {
const assetsSubDirectory = process.env.NODE_ENV === 'production'
Expand Down Expand Up @@ -53,13 +53,9 @@ exports.cssLoaders = function (options) {
resolve('../../components/_style/mixin/util.styl')
]

if (isProd) {
stylusMixins.push(resolve('../../components/_style/mixin/theme.variable.styl'))
} else {
stylusMixins.push(resolve('../../components/_style/mixin/theme.components.styl'))
stylusMixins.push(resolve('../../components/_style/mixin/theme.basic.styl'))
stylusMixins.push(resolve('../../examples/theme.custom.styl'))
}
stylusMixins.push(resolve('../../components/_style/mixin/theme.components.styl'))
stylusMixins.push(resolve('../../components/_style/mixin/theme.basic.styl'))
stylusMixins.push(resolve('../../examples/theme.custom.styl'))

return {
css: generateLoaders(),
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@
"create": "node build/component-init.js",
"cz": "npx git-cz",
"clean": "rm -rf ./lib && rm -rf ./lib-vw && rm -rf ./docs/examples",
"build": "npm run clean && npm run build:components && npm run build:mand-mobile && npm run build:mand-mobile-special && node build/rollup/build-vw-responsive",
"build": "npm run clean && npm run build:components && npm run build:mand-mobile && node build/rollup/build-vw-responsive && node build/rollup/build-css-variables",
"build:site": "cd site && npm run generate && npm run build",
"prebuild:example": "npm run build",
"build:example": "cross-env NODE_ENV=production BUILD_TYPE=example node build/rollup/build-example.rollup",
"build:mand-mobile": "cross-env NODE_ENV=production node build/rollup/build-mand-mobile.rollup",
"build:mand-mobile-special": "cross-env NODE_ENV=production BUILD_TYPE=special node build/rollup/build-mand-mobile.rollup",
"build:components": "cross-env NODE_ENV=production && node build/rollup/build-component.rollup",
"build:analysis": "cross-env NODE_ENV=production node build/webpack/build-mand-mobile --analysis",
"lint": "eslint --ext .js,.vue components test/unit/specs test/e2e/specs",
Expand All @@ -43,7 +42,7 @@
"build:webpack:mand-mobile": "cross-env NODE_ENV=production node build/webpack/build-mand-mobile",
"build:webpack:components": "cross-env NODE_ENV=production gulp build --gulpfile gulpfile.js && node build/webpack/build-style-entry",
"codecov": "codecov",
"test": "jest --no-cache --verbose --runInBand --silent"
"test": "jest --no-cache --runInBand"
},
"license": "Apache",
"config": {
Expand Down

0 comments on commit c45fc11

Please sign in to comment.