Skip to content

Commit

Permalink
build(webpack): update webpack loader configure (#1695)
Browse files Browse the repository at this point in the history
  • Loading branch information
hustcc authored Oct 9, 2020
1 parent 0b3ed76 commit 9c10ebe
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 23 deletions.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@
"devDependencies": {
"@antv/gatsby-theme-antv": "^1.0.0-beta.8",
"@babel/core": "^7.10.4",
"@babel/plugin-transform-runtime": "^7.11.5",
"@babel/preset-env": "^7.10.4",
"@babel/runtime": "^7.11.2",
"@commitlint/cli": "^8.2.0",
"@commitlint/config-angular": "^8.2.0",
"@types/jest": "^25.2.1",
Expand Down Expand Up @@ -136,4 +138,4 @@
}
],
"license": "MIT"
}
}
54 changes: 32 additions & 22 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,26 @@ const webpack = require('webpack');
const resolve = require('path').resolve;
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;

const BABEL_OPTIONS = {
presets: [
[
'@babel/preset-env',
{
targets: '> 0.25%, not dead',
},
],
],
plugins: [
[
'@babel/transform-runtime',
{
helpers: false,
regenerator: true,
},
],
],
};

module.exports = {
entry: {
g2plot: './src/index.ts',
Expand All @@ -20,38 +40,28 @@ module.exports = {
rules: [
{
test: /\.ts$/,
use: {
loader: 'ts-loader',
options: {
transpileOnly: true,
use: [
{
loader: 'babel-loader',
options: BABEL_OPTIONS,
},
},
{
loader: 'ts-loader',
options: {
transpileOnly: true,
},
},
]
},
{
test: /\.js$/,
/** bable 只需要处理 node_modules 中的 es6 模块,src 中的交给 ts-loader 即可 */
include: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
},
options: BABEL_OPTIONS,
},
},
{
test: /\.less$/,
use: [
{
loader: 'style-loader', // creates style nodes from JS strings
},
{
loader: 'css-loader', // translates CSS into CommonJS
},
{
loader: 'less-loader', // compiles Less to CSS
},
],
},
],
},
plugins: [
Expand Down

0 comments on commit 9c10ebe

Please sign in to comment.