webpack.demo.base.conf.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. const config = require('../package.json');
  2. const path = require('path');
  3. const webpackBaseConf = require('./webpack.base.conf.js');
  4. const HtmlWebpackPlugin = require('html-webpack-plugin');
  5. const MiniCssExtractPlugin = require("mini-css-extract-plugin");
  6. const merge = require('webpack-merge');
  7. const isDev = process.env.NODE_ENV === 'development';
  8. module.exports = merge(webpackBaseConf, {
  9. entry: {
  10. app: './sites/demo/app.js',
  11. },
  12. output: {
  13. publicPath: '/',
  14. path: path.resolve(__dirname, '../dist/sites/'),
  15. chunkFilename: 'demo/js/[name].[hash:5].js',
  16. filename: isDev ? 'demo/js/[name].js' : 'demo/js/[name].[hash].js'
  17. },
  18. module: {
  19. rules: [
  20. //自定义主题
  21. // {
  22. // test: /\.(sa|sc|c)ss$/,
  23. // use: [
  24. // {
  25. // loader: 'sass-loader',
  26. // options: {
  27. // data: `@import "./sites/demo/asset/css/custom.scss";@import "./src/styles/index.scss"; `,
  28. // },
  29. // }
  30. // ],
  31. // }
  32. ]
  33. },
  34. plugins: [
  35. new HtmlWebpackPlugin({
  36. template: './sites/demo/index.html',
  37. filename:'demo.html'
  38. }),
  39. new MiniCssExtractPlugin({
  40. filename: isDev ? 'demo/css/[name].css' : 'demo/css/[name].[hash].css'
  41. })
  42. ]
  43. });