Skip to content

Commit cdb1927

Browse files
committed
📦 build: add build file
1 parent b81a25f commit cdb1927

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

lib/index.js

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
'use strict';
2+
3+
Object.defineProperty(exports, "__esModule", {
4+
value: true
5+
});
6+
7+
exports.default = function (content) {
8+
if (this.version && this.version >= 2) {
9+
try {
10+
var value = typeof content === 'string' ? JSON.parse(content) : content;
11+
value = JSON.stringify(value).replace(/\u2028/g, '\\u2028').replace(/\u2029/g, '\\u2029');
12+
var code = 'module.exports = function (Component) { Component.options.__i18n = \'' + value + '\' }';
13+
this.callback(null, code);
14+
} catch (err) {
15+
this.emitError(err.message);
16+
this.callback(err);
17+
}
18+
} else {
19+
var message = 'support webpack 2 later';
20+
this.emitError(message);
21+
this.callback(new Error(message));
22+
}
23+
};

0 commit comments

Comments
 (0)