UNPKG

wkb-common-ui

Version:

wkb-ui

152 lines (150 loc) 3.92 kB
"use strict"; const webpack = require("webpack"); const config = require("./config"); const path = require("path"); const VueLoaderPlugin = require("vue-loader/lib/plugin"); const CopyWebpackPlugin = require("copy-webpack-plugin"); const HtmlWebpackPlugin = require("html-webpack-plugin"); const ProgressBarPlugin = require("progress-bar-webpack-plugin"); const MiniCssExtractPlugin = require("mini-css-extract-plugin"); const isProd = process.env.NODE_ENV === "production"; const isPlay = !!process.env.PLAY_ENV; const webpackConfig = { mode: process.env.NODE_ENV, entry: { docs: "./examples/entry.js" }, output: { path: path.resolve(process.cwd(), "./examples/wkb-paltform/"), publicPath: process.env.CI_ENV || "", filename: "[name].[hash:7].js", chunkFilename: isProd ? "[name].[hash:7].js" : "[name].js" }, devServer: { host: "0.0.0.0", port: process.env.PORT || 80, publicPath: "/", hot: true, disableHostCheck: true, proxy: config.proxy }, resolve: { extensions: [".js", ".vue", ".json"], alias: { main: path.resolve(__dirname, "../src"), packages: path.resolve(__dirname, "../packages"), examples: path.resolve(__dirname, "../examples"), "wkb-platform": path.resolve(__dirname, "../") }, modules: ["node_modules"] }, performance: { hints: false }, stats: { children: false }, module: { rules: [ { enforce: "pre", test: /\.(vue|jsx?)$/, exclude: /node_modules/, loader: "eslint-loader" }, { test: /\.(jsx?|babel|es6)$/, include: process.cwd(), exclude: /node_modules|utils\/popper\.js|utils\/date\.js/, loader: "babel-loader" }, { test: /\.vue$/, loader: "vue-loader", options: { compilerOptions: { preserveWhitespace: false } } }, { test: /\.(scss|css)$/, use: [ isProd ? MiniCssExtractPlugin.loader : "style-loader", "css-loader", "sass-loader" ] }, { test: /\.md$/, use: [ { loader: "vue-loader", options: { compilerOptions: { preserveWhitespace: false } } }, { loader: path.resolve(__dirname, "./md-loader/index.js") } ] }, { oneOf: [ { test: /\icon-(.*)\.svg$/, use: [ { loader: "babel-loader", options: { presets: ["env"] } }, "vue-svg-loader" ] }, { test: /\.(svg|otf|ttf|woff2?|eot|gif|png|jpe?g)(\?\S*)?$/, loader: "url-loader", exclude: [path.resolve(__dirname, "../packages/icon/svg")], // todo: 这种写法有待调整 query: { limit: 10000, name: path.posix.join("static", "[name].[hash:7].[ext]") } } ] } ] }, plugins: [ new webpack.DefinePlugin({ "process.env": require("../config/dev.env") }), new ProgressBarPlugin(), new VueLoaderPlugin(), new webpack.HotModuleReplacementPlugin(), // https://github.com/ampedandwired/html-webpack-plugin new HtmlWebpackPlugin({ filename: "./index.html", template: "index.html", favicon: "./examples/favicon.ico" }), // copy custom static assets new CopyWebpackPlugin([{ from: "examples/versions.json" }]), new webpack.LoaderOptionsPlugin({ vue: { compilerOptions: { preserveWhitespace: false } } }) ], optimization: { minimizer: [] }, devtool: "#eval-source-map" }; module.exports = webpackConfig;