ant-design-vue/webpack.config.js

109 lines
2.6 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 webpack = require('webpack');
const WebpackBar = require('webpackbar');
const path = require('path');
module.exports = {
mode: 'development',
entry: {
app: './examples/index.js',
},
module: {
rules: [
{
test: /\.vue$/,
loader: 'vue-loader',
},
{
test: /\.(js|jsx)$/,
loader: 'babel-loader',
options: {
presets: [
[
2020-05-27 19:11:46 +08:00
'@babel/preset-env',
2020-03-23 11:00:24 +08:00
{
targets: {
browsers: [
'last 2 versions',
'Firefox ESR',
'> 1%',
'ie >= 9',
'iOS >= 8',
'Android >= 4',
],
},
},
],
],
plugins: [
2020-05-27 19:11:46 +08:00
['@ant-design-vue/babel-plugin-jsx', { transformOn: true, compatibleProps: true }],
'@babel/plugin-transform-object-assign',
'@babel/plugin-proposal-object-rest-spread',
'@babel/plugin-proposal-export-default-from',
'@babel/plugin-proposal-class-properties',
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-05-27 19:11:46 +08:00
use: ['css-loader'],
2020-03-23 11:00:24 +08:00
},
],
},
resolve: {
alias: {
'ant-design-vue': path.join(__dirname, './components'),
2020-05-27 19:11:46 +08:00
// vue$: 'vue/dist/vue.esm.js',
2020-03-23 11:00:24 +08:00
},
extensions: ['.js', '.jsx', '.vue'],
},
devServer: {
host: 'localhost',
2020-04-15 21:59:55 +08:00
port: 3002,
2020-03-23 11:00:24 +08:00
historyApiFallback: {
rewrites: [{ from: /./, to: '/index.html' }],
},
disableHostCheck: true,
hot: true,
open: true,
},
devtool: '#source-map',
plugins: [
new webpack.HotModuleReplacementPlugin(),
new HtmlWebpackPlugin({
template: 'examples/index.html',
filename: 'index.html',
inject: true,
}),
new VueLoaderPlugin(),
new WebpackBar(),
],
};