PHP Classes

File: webpack.config.js

Recommend this page to a friend!
  Classes of Maniruzzaman Akash   Event Story Manager Plugin   webpack.config.js   Download  
File: webpack.config.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: Event Story Manager Plugin
Manage and publish regional events in WordPress
Author: By
Last change:
Date: 3 months ago
Size: 3,425 bytes
 

Contents

Class file image Download
const webpack = require('webpack'); const path = require('path'); const UglifyJsPlugin = require('uglifyjs-webpack-plugin'); const ExtractTextPlugin = require('extract-text-webpack-plugin'); const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin'); // Naming and path settings var appName = 'app'; var entryPoint = { 'event-story-admin': './src/js/event-story-admin.js', 'event-story': './src/js/event-story.js', 'admin-style': './src/less/admin.less', 'frontend-style': './src/less/style.less', }; var exportPath = path.resolve(__dirname, './assets/js'); // Enviroment flag var plugins = []; var env = process.env.WEBPACK_ENV; function isProduction() { return process.env.WEBPACK_ENV === 'production'; } // extract css into its own file const extractCss = new ExtractTextPlugin({ filename: "../css/[name].css" }); plugins.push( extractCss ); // Compress extracted CSS. We are using this plugin so that possible // duplicated CSS from different components can be deduped. plugins.push(new OptimizeCSSPlugin({ cssProcessorOptions: { safe: true, map: { inline: false } } })); // Differ settings based on production flag if ( isProduction() ) { plugins.push(new UglifyJsPlugin({ sourceMap: false, })); plugins.push(new webpack.DefinePlugin({ 'process.env': env })); appName = '[name].min.js'; } else { appName = '[name].js'; } module.exports = { entry: entryPoint, output: { path: exportPath, filename: appName, chunkFilename: 'chunks/[chunkhash].js', jsonpFunction: 'eventStoryWebpack' }, resolve: { alias: { 'vue$': 'vue/dist/vue.esm.js', '@': path.resolve('./src/'), 'frontend': path.resolve('./src/frontend/'), 'admin': path.resolve('./src/admin/'), }, modules: [ path.resolve('./node_modules'), path.resolve(path.join(__dirname, 'src/')), ] }, externals: { jquery: 'jQuery', 'chart.js': 'Chart', moment: 'moment' }, plugins, module: { rules: [ { test: /\.js$/, exclude: /node_modules/, use: [ { loader: require.resolve( 'babel-loader' ), options: { // Babel uses a directory within local node_modules // by default. Use the environment variable option // to enable more persistent caching. cacheDirectory: process.env.BABEL_CACHE_DIRECTORY || true, }, }, ], }, { test: /\.vue$/, loader: 'vue-loader', options: { extractCSS: true } }, { test: /\.less$/, use: extractCss.extract({ use: [{ loader: "css-loader" }, { loader: "less-loader" }] }) }, { test: /\.css$/, use: [ 'style-loader', 'css-loader' ] } ] }, }