| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- const config = require('../package.json');
- const path = require('path');
- const webpackBaseConf = require('./webpack.base.conf.js');
- const HtmlWebpackPlugin = require('html-webpack-plugin');
- const MiniCssExtractPlugin = require("mini-css-extract-plugin");
- const merge = require('webpack-merge');
- const mdtohtml = require('../scripts/mdToVue');
- const isDev = process.env.NODE_ENV === 'development';
- module.exports = merge(webpackBaseConf, {
- mode: 'development',
- entry: {
- 'nutui-mobile': './sites/demo/app.js',
- 'nutui-doc': './sites/doc/app.js',
- },
- output: {
- publicPath: '/',
- filename: '[name].js',
- },
- module: {
- rules: [
- //自定义主题
- // {
- // test: /\.(sa|sc|c)ss$/,
- // use: [
- // {
- // loader: 'sass-loader',
- // options: {
- // data: `@import "./sites/demo/asset/css/custom.scss";@import "./src/styles/index.scss"; `,
- // },
- // }
- // ],
- // }
- ]
- },
- optimization: {
- splitChunks: {
- cacheGroups: {
- chunks: {
- chunks: 'all',
- minChunks: 2,
- minSize: 0,
- name: 'chunks'
- }
- }
- }
- },
- plugins: [
- //demo
- new HtmlWebpackPlugin({
- template: './sites/demo/index.html',
- filename: 'demo.html',
- hash: true,//防止缓存
- inject: true,
- chunks: ['chunks', 'nutui-mobile'],
- minify: {
- multihtmlCache: true,// 解决多页打包的关键!
- minifyJS: true,
- minifyCSS: true,
- removeAttributeQuotes: true//压缩 去掉引号
- }
- }),
- // doc
- new mdtohtml({
- entry: './src',
- output: './sites/doc/view/',
- template: './doc-site/template.html',
- nav: 'left',
- needCode: true,
- isbuild: isDev,
- hasMarkList: false
- }),
- new mdtohtml({
- entry: './docs',
- output: './sites/doc/page/',
- template: './doc-site/template.html',
- nav: 'left',
- needCode: false,
- isbuild: isDev
- }),
- new HtmlWebpackPlugin({
- template: './sites/doc/index.html',
- filename: 'default.html',
- hash: true,//防止缓存
- inject: true,
- chunks: ['chunks', 'nutui-doc'],
- minify: {
- multihtmlCache: true,// 解决多页打包的关键!
- minifyJS: true,
- minifyCSS: true,
- removeAttributeQuotes: true//压缩 去掉引号
- }
- }),
- ],
- devtool: 'cheap-module-eval-source-map',
- devServer: {
- contentBase: path.resolve(__dirname, 'dist/sites'),
- compress: true,
- index: 'default.html',
- historyApiFallback: true,
- disableHostCheck: true,
- host: "0.0.0.0",
- hot: true,
- hotOnly: true,
- inline: true,
- overlay: {
- warnings: true,
- errors: true
- },
- watchOptions: {
- ignored: /node_modules/
- }
- }
- });
|