Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const HtmlWebpackPlugin = require('html-webpack-plugin');
- const path = require('path');
- const webpack = require('webpack');
- const normalize = require('node-normalize-scss').includePaths;
- const MiniCssExtractPlugin = require('mini-css-extract-plugin');
- const sourcePath = path.join(__dirname, 'src');
- const buildPath = path.join(__dirname, 'dist');
- module.exports = env => {
- const NODE_ENV = env ? env.NODE_ENV : 'developmet';
- return {
- entry: {
- app: path.resolve(sourcePath, 'entrypoint.js'),
- common: ['react', 'react-dom']
- },
- output: {
- path: buildPath,
- chunkFilename: '[name]-[chunkhash:7].js',
- publicPath: '/admin/'
- },
- module: {
- rules: [
- {
- test: /\.(sass|scss|css)$/,
- use: [
- MiniCssExtractPlugin.loader,
- 'css-loader',
- 'postcss-loader',
- `sass-loader?includePaths[]=${normalize}`
- ]
- },
- {
- test: /\.html$/,
- exclude: /(node_modules)/,
- use: [{ loader: 'html-loader', options: { minimize: true } }]
- },
- {
- test: /\.(js)$/,
- exclude: /(node_modules|assets)/,
- use: ['babel-loader']
- },
- {
- test: /\.(png|jpe?g|gif|svg)$/i,
- use: ['file-loader?limit=5000&name=assets/images/[name].[ext]']
- },
- {
- test: /\.(woff|woff2|ttf|eot)$/,
- use: ['file-loader?name=fonts/[name].[ext]']
- },
- {
- test: /\.(ico)$/,
- exclude: /(node_modules)/,
- use: [
- {
- loader: 'file-loader',
- options: {
- name: '[name].[ext]'
- }
- }
- ]
- }
- ]
- },
- plugins: [
- new webpack.ProvidePlugin({
- $: 'jquery/dist/jquery.min',
- jQuery: 'jquery/dist/jquery.min',
- 'window.jQuery': 'jquery/dist/jquery.min'
- }),
- new HtmlWebpackPlugin({
- template: 'assets/index.html',
- filename: 'index.html',
- favicon: 'assets/favicon.ico'
- }),
- new MiniCssExtractPlugin({
- filename: '[name].css',
- chunkFilename: '[id].css'
- })
- ]
- };
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement