Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const path = require('path');
- const HtmlWebpackPlugin = require('html-webpack-plugin');
- require('@babel/polyfill');
- module.exports = {
- entry: {
- index: ['@babel/polyfill', './src/index.js'],
- login: ['@babel/polyfill', './src/login.js']
- },
- output: {
- path: path.resolve('dist'),
- filename: '[name].js',
- chunkFilename: 'index',
- publicPath: './'
- },
- mode: process.env.NODE_ENV || 'development',
- resolve: {
- modules: [path.resolve(__dirname, 'src'), 'node_modules'],
- extensions: ['.js', '.jsx']
- },
- devServer: {
- historyApiFallback: {
- disableDotRule: true,
- // 指明哪些路径映射到哪个html
- rewrites: [{ from: /^\/login.html/, to: '/dist/login.html' }]
- },
- port: 8099
- },
- module: {
- rules: [
- {
- // this is so that we can compile any React,
- // ES6 and above into normal ES5 syntax
- test: /\.(js|jsx)$/,
- // we do not want anything from node_modules to be compiled
- exclude: /node_modules/,
- use: ['babel-loader']
- },
- {
- test: /\.(css|scss)$/,
- use: [
- 'style-loader', // creates style nodes from JS strings
- 'css-loader', // translates CSS into CommonJS
- 'sass-loader' // compiles Sass to CSS, using Node Sass by default
- ]
- },
- {
- test: /\.(eot|woff|woff2|ttf|svg|png|jpg|gif)$/,
- loaders: ['file-loader']
- }
- ]
- },
- plugins: [
- new HtmlWebpackPlugin({
- inject: true,
- filename: 'index.html',
- template: 'public/index.html',
- chunks: ['index']
- }),
- new HtmlWebpackPlugin({
- inject: true,
- filename: 'login.html',
- template: 'public/login.html',
- chunks: ['login']
- })
- ]
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement