babel-plugin-tree-shaking-import
v1.1.2
Published
Modular build plugin for babel.
Downloads
86
Readme
babel-plugin-tree-shaking-import
Install
npm i babel-plugin-tree-shaking-import -D
or
yarn add babel-plugin-tree-shaking-import -D
Example
Converts
import { Button } from 'element-ui';
to
var button = require('element-ui/lib/button.js');
require('element-ui/packages/theme-chalk/src/button.scss');
Usage
Use with babel-loader
module.exports = {
module: {
rules: [
{
test: /\.m?js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
options: {
plugins: [
[
'tree-shaking-import',
{
libraryName: 'element-ui',
libDir: 'lib',
styleLibraryDir: 'packages',
styleLibraryName: 'theme-chalk/src',
style: false,
ext: '.scss',
},
],
],
},
},
},
],
},
};
Use with nuxt.config.js
module.exports = {
babel: {
plugins: [
[
'tree-shaking-import',
{
libraryName: 'element-ui',
libDir: 'lib',
styleLibraryDir: 'packages',
styleLibraryName: 'theme-chalk/src',
style: false,
ext: '.scss',
},
],
],
},
};