Commit 04fb29abf444a7838edf33c616a2a6ddee75a922
Committed by
GitHub
Merge pull request #1374 from lcx960324/2.0
Packaging locale to dist/locale
Showing
3 changed files
with
42 additions
and
1 deletions
Show diff stats
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 | \ No newline at end of file | 9 | \ No newline at end of file |
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 | \ No newline at end of file | 33 | \ No newline at end of file |
package.json
@@ -23,7 +23,8 @@ | @@ -23,7 +23,8 @@ | ||
23 | "dist:style": "gulp --gulpfile build/build-style.js", | 23 | "dist:style": "gulp --gulpfile build/build-style.js", |
24 | "dist:dev": "webpack --config build/webpack.dist.dev.config.js", | 24 | "dist:dev": "webpack --config build/webpack.dist.dev.config.js", |
25 | "dist:prod": "webpack --config build/webpack.dist.prod.config.js", | 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 | "lint": "eslint --fix --ext .js,.vue src", | 28 | "lint": "eslint --fix --ext .js,.vue src", |
28 | "unit": "cross-env BABEL_ENV=test karma start test/unit/karma.conf.js --single-run", | 29 | "unit": "cross-env BABEL_ENV=test karma start test/unit/karma.conf.js --single-run", |
29 | "test": "npm run lint && npm run unit", | 30 | "test": "npm run lint && npm run unit", |