Commit 04fb29abf444a7838edf33c616a2a6ddee75a922

Authored by Aresn
Committed by GitHub
2 parents 1c26046d f3cbb62b

Merge pull request #1374 from lcx960324/2.0

Packaging locale to dist/locale
build/locale.js 0 → 100644
  1 +const readDir = require('fs').readdirSync
  2 +const files = readDir('./src/locale/lang')
  3 +const entry = {}
  4 +files.forEach(file => {
  5 + const name = file.split('.')[0]
  6 + entry[name] = './src/locale/lang/' + file
  7 +})
  8 +module.exports = entry
0 9 \ No newline at end of file
... ...
build/webpack.dist.locale.config.js 0 → 100644
  1 +var path = require('path');
  2 +var webpack = require('webpack');
  3 +var entry = require('./locale');
  4 +process.env.NODE_ENV = 'production';
  5 +
  6 +module.exports = {
  7 + entry,
  8 + module: {
  9 + rules: [
  10 + {
  11 + test: /\.js$/,
  12 + loader: 'babel-loader',
  13 + exclude: /node_modules/
  14 + }
  15 + ],
  16 + },
  17 + output: {
  18 + path: path.resolve(__dirname, '../dist/locale'),
  19 + publicPath: '/dist/locale/',
  20 + filename: '[name].js',
  21 + library: 'iview/locale',
  22 + libraryTarget: 'umd',
  23 + umdNamedDefine: true
  24 + },
  25 + plugins: [
  26 + new webpack.DefinePlugin({
  27 + 'process.env': {
  28 + NODE_ENV: '"production"'
  29 + }
  30 + })
  31 + ]
  32 +}
0 33 \ No newline at end of file
... ...
package.json
... ... @@ -23,7 +23,8 @@
23 23 "dist:style": "gulp --gulpfile build/build-style.js",
24 24 "dist:dev": "webpack --config build/webpack.dist.dev.config.js",
25 25 "dist:prod": "webpack --config build/webpack.dist.prod.config.js",
26   - "dist": "npm run dist:style && npm run dist:dev && npm run dist:prod",
  26 + "dist:locale": "webpack --config build/webpack.dist.locale.config.js",
  27 + "dist": "npm run dist:style && npm run dist:dev && npm run dist:prod && npm run dist:locale",
27 28 "lint": "eslint --fix --ext .js,.vue src",
28 29 "unit": "cross-env BABEL_ENV=test karma start test/unit/karma.conf.js --single-run",
29 30 "test": "npm run lint && npm run unit",
... ...