Advertisement
Guest User

webpack.config.js

a guest
Feb 29th, 2020
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const webpack = require('webpack');
  2. const path = require('path');
  3.  
  4. module.exports = env => {
  5.  
  6.   return {
  7.     devtool: 'eval',
  8.     mode: 'development',
  9.     entry: ['index.jsx'],
  10.     output: {
  11.       filename: 'app.js',
  12.       publicPath: 'dist',
  13.       path: path.resolve('dist'),
  14.     },
  15.     devServer: {
  16.       port: 3001,
  17.       historyApiFallback: {
  18.         disableDotRule: true
  19.       },
  20.       inline: true,
  21.     },
  22.     resolve: {
  23.       extensions: ['.jsx', '.js'],
  24.  
  25.       modules: ['src', 'node_modules'],
  26.       alias: {
  27.         $fff: path.resolve('/code/fff/src/')
  28.       }
  29.     },
  30.  
  31.     module: {
  32.       rules: [
  33.         {
  34.           test: /\.jsx?$/,
  35.           include: [
  36.             path.resolve(__dirname),
  37.             path.resolve('/code/fff/src/')
  38.           ],
  39.           exclude: /node_modules/,
  40.           loader: "babel-loader",
  41.         },
  42.         {
  43.           test: /\.scss$/,
  44.           use: [{
  45.               loader: "style-loader"
  46.           }, {
  47.               loader: "css-loader"
  48.           }, {
  49.               loader: "sass-loader",
  50.               options: {
  51.                   mimtype: "text/css",
  52.                   includePaths: []
  53.               }
  54.           }]
  55.         },
  56.         {
  57.           test: /\.css$/,
  58.           use: [{
  59.               loader: "style-loader"
  60.           }, {
  61.               loader: "css-loader"
  62.           }, {
  63.               loader: "sass-loader",
  64.               options: {
  65.                   mimtype: "text/css",
  66.                   includePaths: []
  67.               }
  68.           }]
  69.         },
  70.         {
  71.           test: /\.(svg|png|ico|xml|json)$/,
  72.           loaders: ['file-loader'],
  73.           include: path.resolve('assets')
  74.         },
  75.       ],
  76.     },
  77.  
  78.  
  79.     plugins: [
  80.       new webpack.DefinePlugin({
  81.         __API_URL: JSON.stringify(env.development ? 'https://localhost:44341/api/' : 'https://xxx/api/'),
  82.         __APPLICATION_KEY: JSON.stringify('CrossCheck')
  83.       })
  84.     ]
  85.  
  86.   };
  87. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement