Merge pull request #1374 from lcx960324/2.0

Packaging locale to dist/locale
This commit is contained in:
Aresn 2017-07-18 09:50:28 +08:00 committed by GitHub
commit 04fb29abf4
3 changed files with 42 additions and 1 deletions

8
build/locale.js Normal file
View file

@ -0,0 +1,8 @@
const readDir = require('fs').readdirSync
const files = readDir('./src/locale/lang')
const entry = {}
files.forEach(file => {
const name = file.split('.')[0]
entry[name] = './src/locale/lang/' + file
})
module.exports = entry

View file

@ -0,0 +1,32 @@
var path = require('path');
var webpack = require('webpack');
var entry = require('./locale');
process.env.NODE_ENV = 'production';
module.exports = {
entry,
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/
}
],
},
output: {
path: path.resolve(__dirname, '../dist/locale'),
publicPath: '/dist/locale/',
filename: '[name].js',
library: 'iview/locale',
libraryTarget: 'umd',
umdNamedDefine: true
},
plugins: [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"'
}
})
]
}

View file

@ -23,7 +23,8 @@
"dist:style": "gulp --gulpfile build/build-style.js",
"dist:dev": "webpack --config build/webpack.dist.dev.config.js",
"dist:prod": "webpack --config build/webpack.dist.prod.config.js",
"dist": "npm run dist:style && npm run dist:dev && npm run dist:prod",
"dist:locale": "webpack --config build/webpack.dist.locale.config.js",
"dist": "npm run dist:style && npm run dist:dev && npm run dist:prod && npm run dist:locale",
"lint": "eslint --fix --ext .js,.vue src",
"unit": "cross-env BABEL_ENV=test karma start test/unit/karma.conf.js --single-run",
"test": "npm run lint && npm run unit",