Advertisement
ahmadandika

webpack develop loccitane

Oct 22nd, 2019
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const path = require('path');
  2. const HtmlWebpackPlugin = require('html-webpack-plugin');
  3. require('@babel/polyfill');
  4.  
  5. module.exports = {
  6.   entry: {
  7.     index: ['@babel/polyfill', './src/index.js'],
  8.     login: ['@babel/polyfill', './src/login.js']
  9.   },
  10.   output: {
  11.     path: path.resolve('dist'),
  12.     filename: '[name].js',
  13.     chunkFilename: 'index',
  14.     publicPath: '/'
  15.   },
  16.   mode: process.env.NODE_ENV || 'development',
  17.   resolve: {
  18.     modules: [path.resolve(__dirname, 'src'), 'node_modules'],
  19.     extensions: ['.js', '.jsx']
  20.   },
  21.   devServer: {
  22.     historyApiFallback: {
  23.       disableDotRule: true,
  24.       // 指明哪些路径映射到哪个html
  25.       rewrites: [{ from: /^\/login.html/, to: '/dist/login.html' }]
  26.     },
  27.  
  28.     port: 8099
  29.   },
  30.   module: {
  31.     rules: [
  32.       {
  33.         // this is so that we can compile any React,
  34.         // ES6 and above into normal ES5 syntax
  35.         test: /\.(js|jsx)$/,
  36.         // we do not want anything from node_modules to be compiled
  37.         exclude: /node_modules/,
  38.         use: ['babel-loader']
  39.       },
  40.       {
  41.         test: /\.(css|scss)$/,
  42.         use: [
  43.           'style-loader', // creates style nodes from JS strings
  44.           'css-loader', // translates CSS into CommonJS
  45.           'sass-loader' // compiles Sass to CSS, using Node Sass by default
  46.         ]
  47.       },
  48.       {
  49.         test: /\.(eot|woff|woff2|ttf|svg|png|jpg|gif)$/,
  50.         loaders: ['file-loader']
  51.       }
  52.     ]
  53.   },
  54.   plugins: [
  55.     new HtmlWebpackPlugin({
  56.       inject: true,
  57.       filename: 'index.html',
  58.       template: 'public/index.html',
  59.       chunks: ['index']
  60.     }),
  61.     new HtmlWebpackPlugin({
  62.       inject: true,
  63.       filename: 'login.html',
  64.       template: 'public/login.html',
  65.       chunks: ['login']
  66.     })
  67.   ]
  68. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement