Skip to content

Commit 17a9b47

Browse files
committed
feat: 支持分包
1 parent 22da4ab commit 17a9b47

File tree

5 files changed

+75
-6
lines changed

5 files changed

+75
-6
lines changed

.babelrc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"presets": [
3+
["env", {
4+
"modules": false,
5+
"targets": {
6+
"browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
7+
}
8+
}],
9+
"stage-2"
10+
],
11+
"plugins": ["transform-runtime"],
12+
"env": {
13+
"test": {
14+
"presets": ["env", "stage-2"],
15+
"plugins": ["istanbul"]
16+
}
17+
}
18+
}

.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true

.eslintrc.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// http://eslint.org/docs/user-guide/configuring
2+
3+
module.exports = {
4+
root: true,
5+
parser: 'babel-eslint',
6+
parserOptions: {
7+
sourceType: 'module'
8+
},
9+
env: {
10+
browser: false,
11+
node: true,
12+
es6: true
13+
},
14+
// https://github.com/standard/standard/blob/master/docs/RULES-en.md
15+
extends: 'standard',
16+
// required to lint *.vue files
17+
plugins: [
18+
'html'
19+
],
20+
// add your custom rules here
21+
'rules': {
22+
// allow paren-less arrow functions
23+
'arrow-parens': 0,
24+
// allow async-await
25+
'generator-star-spacing': 0,
26+
// allow debugger during development
27+
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0
28+
},
29+
globals: {
30+
App: true,
31+
Page: true,
32+
wx: true,
33+
getApp: true,
34+
getPage: true,
35+
requirePlugin: true
36+
}
37+
}

index.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
const path = require('path');
2+
const relative = require('relative');
3+
14
function MpvuePlugin() {}
25

36
MpvuePlugin.prototype.apply = function(compiler) {
4-
const {options: {entry, plugins}} = compiler;
57
compiler.plugin('emit', function(compilation, callback) {
68
let commonsChunkNames = [];
79
// 获取所有的 chunk name
@@ -15,7 +17,7 @@ MpvuePlugin.prototype.apply = function(compiler) {
1517
compilation.chunks.forEach(commonChunk => {
1618
const { files, chunks: childChunks, name } = commonChunk;
1719
let commonWxssFile = files.find(item => item.endsWith('.wxss'));
18-
20+
1921
if (commonsChunkNames.indexOf(name) > -1 && commonWxssFile) {
2022
childChunks.forEach(item => {
2123
let wxssFile = item.files.find(item => item.endsWith('.wxss'));
@@ -30,10 +32,10 @@ MpvuePlugin.prototype.apply = function(compiler) {
3032
console.error(error, wxssFile)
3133
}
3234
})
33-
}
34-
});
35+
})
36+
})
3537
callback();
3638
});
3739
};
3840

39-
module.exports = MpvuePlugin;
41+
module.exports = MpvuePlugin;

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,8 @@
2222
"url": "https://github.com/mpvue/webpack-mpvue-asset-plugin/issues"
2323
},
2424
"homepage": "https://github.com/mpvue/webpack-mpvue-asset-plugin#readme",
25-
"description": ""
25+
"description": "",
26+
"dependencies": {
27+
"relative": "^3.0.2"
28+
}
2629
}

0 commit comments

Comments
 (0)