| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- const path = require('path');
- const webpack = require('webpack');
- const GitRevisionPlugin = require('git-revision-webpack-plugin');
- const gitRevisionPlugin = new GitRevisionPlugin();
- const autoprefixer = require('autoprefixer');
- const cssnano = require('cssnano');
- module.exports = {
- mode: 'development',
- devtool: 'cheap-module-source-map',
- entry: {
- DPlayer: './src/js/index.js',
- },
- output: {
- path: path.resolve(__dirname, '..', 'dist'),
- filename: '[name].js',
- library: '[name]',
- libraryTarget: 'umd',
- libraryExport: 'default',
- umdNamedDefine: true,
- publicPath: '/',
- },
- resolve: {
- modules: ['node_modules'],
- extensions: ['.js', '.scss'],
- },
- module: {
- strictExportPresence: true,
- rules: [
- {
- test: /\.js$/,
- use: [
- {
- loader: 'babel-loader',
- options: {
- cacheDirectory: true,
- presets: ['@babel/preset-env'],
- },
- },
- ],
- },
- {
- test: /\.scss$/,
- use: [
- 'style-loader',
- {
- loader: 'css-loader',
- options: {
- importLoaders: 1,
- },
- },
- {
- loader: 'postcss-loader',
- options: {
- plugins: [autoprefixer, cssnano],
- },
- },
- 'sass-loader',
- ],
- },
- {
- test: /\.(png|jpg)$/,
- loader: 'url-loader',
- options: {
- limit: 40000,
- },
- },
- {
- test: /\.svg$/,
- loader: 'svg-inline-loader',
- },
- {
- test: /\.art$/,
- loader: 'art-template-loader',
- },
- ],
- },
- devServer: {
- compress: true,
- contentBase: path.resolve(__dirname, '..', 'demo'),
- clientLogLevel: 'none',
- quiet: false,
- open: true,
- historyApiFallback: {
- disableDotRule: true,
- },
- watchOptions: {
- ignored: /node_modules/,
- },
- },
- plugins: [
- new webpack.DefinePlugin({
- DPLAYER_VERSION: `"${require('../package.json').version}"`,
- GIT_HASH: JSON.stringify(gitRevisionPlugin.version()),
- }),
- ],
- node: {
- dgram: 'empty',
- fs: 'empty',
- net: 'empty',
- tls: 'empty',
- },
- performance: {
- hints: false,
- },
- };
|