Files
hoc-element-affix/build/webpack.example.js

145 lines
3.3 KiB
JavaScript
Raw Normal View History

2022-01-01 16:14:33 +08:00
const webpack = require('webpack')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const { VueLoaderPlugin } = require('vue-loader')
const ESLintPlugin = require('eslint-webpack-plugin')
2020-10-06 17:03:32 +08:00
2022-01-01 16:14:33 +08:00
const { resolve } = require('./utils')
2020-10-06 17:03:32 +08:00
2022-01-01 16:14:33 +08:00
/**
* @type { webpack.Configuration }
*/
2020-10-06 17:03:32 +08:00
const webpackConfig = {
mode: process.env.NODE_ENV,
2022-01-01 16:14:33 +08:00
target: 'web',
2020-10-06 17:03:32 +08:00
entry: './example/main.js',
output: {
path: resolve('./example/dist'),
2022-01-01 16:14:33 +08:00
filename: '[name].[fullhash:7].js'
2020-10-06 17:03:32 +08:00
},
resolve: {
alias: {
2022-01-01 16:14:33 +08:00
root: resolve(),
vue$: 'vue/dist/vue.esm-bundler.js',
'@': resolve('./src'),
example: resolve('./example/src')
// Non-essential, turn it on when using npm link
// vue: resolve('./node_modules/vue')
2020-10-06 17:03:32 +08:00
},
extensions: ['*', '.js', '.vue', '.json']
2022-01-01 16:14:33 +08:00
// Non-essential, turn it on when using npm link
// symlinks: false
2020-10-06 17:03:32 +08:00
},
devServer: {
2022-01-01 16:14:33 +08:00
port: 8086,
historyApiFallback: true,
2020-10-06 17:03:32 +08:00
},
performance: {
hints: false
},
module: {
rules: [
{
test: /\.(jsx?|babel|es6)$/,
include: process.cwd(),
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
extends: resolve('babel.config.js')
}
}
},
{
test: /\.vue$/,
loader: 'vue-loader',
options: {
compilerOptions: {
preserveWhitespace: false
}
}
},
{
2022-01-01 16:14:33 +08:00
test: /\.css$/,
use: [
'vue-style-loader',
'css-loader'
]
},
{
test: /\.s(c|a)ss$/,
2020-10-06 17:03:32 +08:00
use: [
'vue-style-loader',
'css-loader',
2022-01-01 16:14:33 +08:00
{
loader: 'sass-loader',
options: {
// Prefer `dart-sass`
implementation: require('sass')
}
}
2020-10-06 17:03:32 +08:00
]
},
{
2022-01-01 16:14:33 +08:00
test: /\.(png|jpe?g|gif|svg|webp)(\?.*)?$/,
2020-10-06 17:03:32 +08:00
loader: 'url-loader',
2022-01-01 16:14:33 +08:00
exclude: /node_modules/,
options: {
2020-10-06 17:03:32 +08:00
limit: 10000,
2022-01-01 16:14:33 +08:00
esModule: false,
name: '[name].[fullhash:7].[ext]'
}
},
{
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
loader: 'url-loader',
exclude: /node_modules/,
options: {
limit: 10000,
name: '[name].[fullhash:7].[ext]'
}
},
{
test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
loader: 'url-loader',
exclude: /node_modules/,
options: {
limit: 10000,
name: '[name].[fullhash:7].[ext]'
}
},
{
test: /\.(png|jpe?g|gif|svg|webp|woff2?|eot|ttf|otf|mp4|webm|ogg|mp3|wav|flac|aac)(\?\S*)?$/,
loader: 'file-loader',
include: /node_modules/,
options: {
name: '[name].[ext]?[fullhash]'
2020-10-06 17:03:32 +08:00
}
}
]
},
plugins: [
2022-01-01 16:14:33 +08:00
new ESLintPlugin(),
2020-10-06 17:03:32 +08:00
new HtmlWebpackPlugin({
2022-01-01 16:14:33 +08:00
template: './example/index.html'
2020-10-06 17:03:32 +08:00
}),
new VueLoaderPlugin(),
new webpack.LoaderOptionsPlugin({
vue: {
compilerOptions: {
preserveWhitespace: false
}
}
}),
2022-01-01 16:14:33 +08:00
new webpack.DefinePlugin({
__VUE_OPTIONS_API__: false,
__VUE_PROD_DEVTOOLS__: false,
}),
2020-10-06 17:03:32 +08:00
],
optimization: {
minimizer: []
},
2022-01-01 16:14:33 +08:00
devtool: 'eval-source-map'
}
2020-10-06 17:03:32 +08:00
2022-01-01 16:14:33 +08:00
module.exports = webpackConfig