Skip to content

Commit 95b4338

Browse files
authored
fix: babel-loader work incorrectly with .babelrc (#392)
1 parent 80f9bac commit 95b4338

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed

.babelrc

+7-7
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@
55
{
66
"modules": "umd",
77
"targets": {
8-
"ie": "9",
9-
},
10-
},
11-
],
8+
"ie": "9"
9+
}
10+
}
11+
]
1212
],
1313
"plugins": [
1414
[
1515
"@babel/plugin-proposal-class-properties",
1616
{
17-
"loose": true,
18-
},
17+
"loose": true
18+
}
1919
],
2020
"@babel/plugin-proposal-export-namespace-from",
2121
"@babel/plugin-proposal-object-rest-spread",
2222
"add-module-exports"
23-
],
23+
]
2424
}

webpack.config.js

+15-7
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ const pkg = require('./package.json');
22
const Webpack = require('webpack');
33
const Path = require('path');
44
const CopyWebpackPlugin = require('copy-webpack-plugin');
5+
const fs = require('fs');
56

67
module.exports = {
78
mode: 'production',
89
devtool: false,
910
entry: {
10-
vconsole : Path.resolve(__dirname, './src/vconsole.js')
11+
vconsole: Path.resolve(__dirname, './src/vconsole.js')
1112
},
1213
output: {
1314
path: Path.resolve(__dirname, './dist'),
@@ -19,10 +20,15 @@ module.exports = {
1920
module: {
2021
rules: [
2122
{
22-
test: /\.html$/, loader: 'html-loader?minimize=false'
23+
test: /\.html$/,
24+
loader: 'html-loader?minimize=false'
2325
},
24-
{
25-
test: /\.js$/, loader: 'babel-loader'
26+
{
27+
test: /\.js$/,
28+
loader: 'babel-loader',
29+
options: {
30+
...JSON.parse(fs.readFileSync(Path.resolve(__dirname, '.babelrc'))),
31+
}
2632
},
2733
{
2834
test: /\.less$/,
@@ -34,20 +40,22 @@ module.exports = {
3440
colors: true,
3541
},
3642
plugins: [
37-
new Webpack.BannerPlugin([
43+
new Webpack.BannerPlugin(
44+
[
3845
'vConsole v' + pkg.version + ' (' + pkg.homepage + ')',
3946
'',
4047
'Tencent is pleased to support the open source community by making vConsole available.',
4148
'Copyright (C) 2017 THL A29 Limited, a Tencent company. All rights reserved.',
4249
'Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at',
4350
'http://opensource.org/licenses/MIT',
4451
'Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.'
45-
].join('\n')),
52+
].join('\n')
53+
),
4654
new CopyWebpackPlugin([
4755
{
4856
from: Path.resolve(__dirname, './src/vconsole.d.ts'),
4957
to: Path.resolve(__dirname, './dist/vconsole.min.d.ts')
5058
}
5159
])
5260
]
53-
};
61+
};

0 commit comments

Comments
 (0)