UNPKG

js-dicom

Version:

this is js-dicom

111 lines (105 loc) 2.92 kB
/** *luoyin */ 'use strict' const HtmlWebPackPlugin = require("html-webpack-plugin"); const CleanWebpackPlugin = require('clean-webpack-plugin'); const ExtractTextPlugin = require("extract-text-webpack-plugin"); const WebpackMerge = require("webpack-merge"); const Webpack = require('webpack'); const path = require("path"); var genConfig = { module: { rules: [ { test: /\.js$/, exclude: /node_modules/, use: { loader: "babel-loader" } }, { test: /\.css$/, use: ExtractTextPlugin.extract({ fallback: "style-loader", use: "css-loader" }) }, { test: /\.less$/, use: ExtractTextPlugin.extract({ fallback: "style-loader", use: ["css-loader","less-loader"] }) }, { test: /\.(png|svg|jpg|gif)$/, use: [ 'file-loader' ] }, { test: /\.(woff|woff2|eot|ttf|otf)$/, use: [ 'file-loader' ] }, { test: /\.(csv|tsv)$/, use: [ 'csv-loader' ] }, { test: /\.xml$/, use: [ 'xml-loader' ] } ] }, plugins: [ new CleanWebpackPlugin(['dist'], { root: path.resolve(process.cwd(), './'), varbose: true, dry: false }), new ExtractTextPlugin({ filename:'[name].css', allChunks:true }), new Webpack.optimize.SplitChunksPlugin({ splitChunks: { chunks: "async", minSize: 30000, minChunks: 1, maxAsyncRequests: 5, maxInitialRequests: 3, automaticNameDelimiter: '~', name: true, cacheGroups: { vendors: { test: /[\\/]node_modules[\\/]/, priority: -10 }, default: { minChunks: 2, priority: -20, reuseExistingChunk: true } } } }) ] }; var webConfig = { target: 'web', // <=== 默认是 'web',可省略 entry: { 'js-dicom': './src/index.js' }, output: { path: path.resolve(process.cwd(), 'dist'), libraryTarget:'umd' } }; module.exports = {webConfig: WebpackMerge(webConfig, genConfig)};