UNPKG

react-smartbanner

Version:
126 lines (118 loc) 3.43 kB
/* * Webpack development server configuration * * This file is set up for serving the webpack-dev-server, which will watch for changes and recompile as required if * the subfolder /webpack-dev-server/ is visited. Visiting the root will not automatically reload. */ const webpack = require('webpack'); const paths = require('./paths'); const CopyWebpackPlugin = require('copy-webpack-plugin'); const HtmlWebpackPlugin = require('html-webpack-plugin'); const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin'); const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin'); const WatchMissingNodeModulesPlugin = require('react-dev-utils/WatchMissingNodeModulesPlugin'); const getClientEnvironment = require('./env'); // Webpack uses `publicPath` to determine where the app is being served from. // In development, we always serve from the root. This makes config easier. const publicPath = '/'; // `publicUrl` is just like `publicPath`, but we will provide it to our app // as %PUBLIC_URL% in `index.html` and `process.env.PUBLIC_URL` in JavaScript. // Omit trailing shlash as %PUBLIC_PATH%/xyz looks better than %PUBLIC_PATH%xyz. const publicUrl = ''; // Get enrivonment variables to inject into our app. const env = getClientEnvironment(publicUrl); module.exports = { mode: 'development', devtool: 'cheap-module-source-map', entry: [ require.resolve('react-dev-utils/webpackHotDevClient'), require.resolve('./polyfills'), paths.appExampleJs, ], output: { path: paths.appBuild, pathinfo: true, filename: 'static/js/bundle.js', publicPath: publicPath, }, externals: { react: 'React', 'react-dom': 'ReactDOM', }, resolve: { modules: ['src', 'node_modules', ...paths.nodePaths], alias: { 'react-smartbanner': './components/SmartBanner.js', }, }, module: { rules: [ { test: /\.(js|jsx)$/, enforce: 'pre', include: paths.appSrc, use: { loader: 'eslint-loader', }, }, { exclude: [ /\.html$/, /\.(js|jsx)$/, /\.css$/, /\.scss$/, /\.json$/, /\.png$/, /\.svg$/, ], loader: 'url-loader', options: { limit: 10000, name: 'static/media/[name].[hash:8].[ext]', }, }, { test: /\.(js|jsx)$/, include: paths.appSrc, use: { loader: 'babel-loader', }, }, { test: /\.scss$/, use: [ 'style-loader?sourceMap', 'css-loader', 'sass-loader?outputStyle=expanded', ], }, { test: /\.css$/, use: [{ loader: 'style-loader' }, { loader: 'css-loader' }], }, ], }, plugins: [ new webpack.NormalModuleReplacementPlugin( /^\.\/main\.css$/, '../dist/main.css' ), new CopyWebpackPlugin([{ from: 'src/icon.png', to: './' }]), new HtmlWebpackPlugin({ inject: true, template: paths.appHtml, }), new InterpolateHtmlPlugin(HtmlWebpackPlugin, { PUBLIC_URL: publicUrl, }), new webpack.DefinePlugin(env), new webpack.HotModuleReplacementPlugin(), new CaseSensitivePathsPlugin(), new WatchMissingNodeModulesPlugin(paths.appNodeModules), ], node: { fs: 'empty', net: 'empty', tls: 'empty', }, };