ant-design-vue/webpack.config.js

154 lines
3.5 KiB
JavaScript
Raw Normal View History

2020-03-23 11:00:24 +08:00
const HtmlWebpackPlugin = require('html-webpack-plugin');
2020-05-27 19:11:46 +08:00
const VueLoaderPlugin = require('vue-loader/dist/plugin').default;
2020-03-23 11:00:24 +08:00
const WebpackBar = require('webpackbar');
const path = require('path');
2020-07-07 16:00:49 +08:00
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
2020-03-23 11:00:24 +08:00
2020-08-16 00:21:58 +08:00
const babelConfig = {
cacheDirectory: true,
presets: [
[
'@babel/preset-env',
{
targets: {
browsers: [
'last 2 versions',
'Firefox ESR',
'> 1%',
2020-10-19 17:17:10 +08:00
'ie >= 11',
2020-08-16 00:21:58 +08:00
'iOS >= 8',
'Android >= 4',
],
},
},
],
'@babel/preset-typescript',
],
plugins: [
[
'babel-plugin-import',
{
libraryName: 'ant-design-vue',
libraryDirectory: '', // default: lib
style: true,
},
],
2020-10-07 22:49:01 +08:00
['@vue/babel-plugin-jsx', { mergeProps: false }],
2020-08-16 00:21:58 +08:00
'@babel/plugin-proposal-optional-chaining',
'@babel/plugin-transform-object-assign',
'@babel/plugin-proposal-object-rest-spread',
'@babel/plugin-proposal-export-default-from',
2020-10-19 17:17:10 +08:00
'@babel/plugin-proposal-export-namespace-from',
2020-08-16 00:21:58 +08:00
'@babel/plugin-proposal-class-properties',
],
};
2020-03-23 11:00:24 +08:00
module.exports = {
mode: 'development',
entry: {
app: './examples/index.js',
},
module: {
rules: [
{
2020-06-20 15:14:51 +08:00
test: /\.(vue|md)$/,
2020-03-23 11:00:24 +08:00
loader: 'vue-loader',
2020-07-26 21:35:41 +08:00
exclude: /\.(en-US.md|zh-CN.md)$/,
},
{
test: /\.(en-US.md|zh-CN.md)$/,
use: [{ loader: 'vue-loader' }, { loader: './loader.js' }],
2020-03-23 11:00:24 +08:00
},
2020-08-16 00:21:58 +08:00
{
test: /\.tsx?$/,
use: [
{
loader: 'babel-loader',
options: babelConfig,
},
{
loader: 'ts-loader',
options: {
transpileOnly: true,
},
},
],
exclude: /node_modules/,
},
2020-03-23 11:00:24 +08:00
{
test: /\.(js|jsx)$/,
loader: 'babel-loader',
exclude: /pickr.*js/,
2020-08-16 00:21:58 +08:00
options: babelConfig,
2020-03-23 11:00:24 +08:00
},
{
test: /\.(png|jpg|gif|svg)$/,
loader: 'file-loader',
options: {
name: '[name].[ext]?[hash]',
},
},
{
test: /\.less$/,
use: [
2020-05-27 19:11:46 +08:00
{ loader: 'style-loader' },
2020-03-23 11:00:24 +08:00
{
loader: 'css-loader',
options: { sourceMap: true },
},
{
loader: 'less-loader',
options: {
lessOptions: {
sourceMap: true,
javascriptEnabled: true,
},
},
},
2020-03-23 11:00:24 +08:00
],
},
{
test: /\.css$/,
2020-07-07 16:00:49 +08:00
use: [
{
loader: MiniCssExtractPlugin.loader,
options: {
hmr: true,
},
},
'css-loader',
],
2020-03-23 11:00:24 +08:00
},
],
},
resolve: {
alias: {
2020-09-10 16:39:02 +08:00
'ant-design-vue/es': path.join(__dirname, './components'),
2020-03-23 11:00:24 +08:00
'ant-design-vue': path.join(__dirname, './components'),
2020-08-14 13:43:20 +08:00
vue$: 'vue/dist/vue.esm-bundler.js',
2020-03-23 11:00:24 +08:00
},
2020-08-16 00:21:58 +08:00
extensions: ['.js', '.jsx', '.ts', '.tsx', '.vue', '.md'],
2020-03-23 11:00:24 +08:00
},
devServer: {
historyApiFallback: {
rewrites: [{ from: /./, to: '/index.html' }],
},
disableHostCheck: true,
hot: true,
open: true,
},
2020-10-19 16:43:10 +08:00
devtool: 'cheap-module-eval-source-map',
2020-03-23 11:00:24 +08:00
plugins: [
2020-07-07 16:00:49 +08:00
new MiniCssExtractPlugin({
filename: '[name].css',
}),
2020-03-23 11:00:24 +08:00
new HtmlWebpackPlugin({
template: 'examples/index.html',
filename: 'index.html',
inject: true,
}),
new VueLoaderPlugin(),
new WebpackBar(),
],
};