webpack 配置
const path = require('path');
const webpack = require('webpack');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
module.exports = {
entry: './packages/index.js',
output: {
path: path.resolve(__dirname, './lib'),(输出路径)
filename: './atomD.min.js',(输出文件)
library: 'atomD',(设置库名)
libraryTarget: 'umd',(设置 library 规范)
globalObject: 'this',(设置全局环境)
umdNamedDefine: true(umd 规范中输出 amd 的命名)
},
externals: {
vue: {(抽取 vue )
root: 'Vue',
commonjs: 'vue',
commonjs2: 'vue',
amd: 'vue'
}
},
module: {
rules: [
{
test: /\.js$/,
loader: 'eslint-loader',
enforce: 'pre',
exclude: path.resolve(__dirname, '/node_modules')
},
{
test: /\.js$/,
loader: 'babel-loader',
exclude: path.resolve(__dirname, '/node_modules')
},
{
test: /\.css$/,
use: [
MiniCssExtractPlugin.loader,(抽取 css,必须要有 css-loader,其他 loader 要在 css-loader 之后)
'css-loader',
'postcss-loader'
]
}]
},
resolve: {
extensions: ['.js'](默认文件扩展)
},
plugins: [
new CleanWebpackPlugin(),(清空之前打包的文件)
new MiniCssExtractPlugin({filename: 'style.css'})(抽取 css)
]
}
一套 vue 移动端 的 组件 库
https://github.com/Reming960227/atom-design(点个 star, 谢谢)