const path = require('path'); const happyPack = require('happypack'); const MiniCssExtractPlugin = require("mini-css-extract-plugin"); const webpack = require('webpack'); const FriendlyErrorsWebpackPlugin = require('friendly-errors-webpack-plugin'); module.exports = { mode: 'development', entry: {}, output: { filename: '[name].js', path: path.join(__dirname, '../dist'), publicPath: '/', library: '[name]', libraryTarget: 'umd', chunkFilename: '[name][chunkhash:8].js' }, devtool: 'cheap-module-source-map', externals: { '@platform/api': '@platform/api/index', '@platform/base': '@platform/base/index', '@platform/template': '@platform/template/index', '@platform/form': '@platform/form/index', '@platform/search': '@platform/search/index', '@platform/table-core': '@platform/table-core/index', '@platform/card-table': '@platform/card-table/index', '@platform/edit-table': '@platform/edit-table/index', '@platform/simple-table': '@platform/simple-table/index', '@platform/transfer-table': '@platform/transfer-table/index', '@platform/tree-table': '@platform/tree-table/index', '@platform/components': '@platform/components/index', 'nc-lightapp-mobile': 'nc-lightapp-mobile', 'nc-lightapp-front': 'nc-lightapp-front', 'platform-workbench': 'platform-workbench', 'platform-report': 'platform-report', 'platform-login': 'platform-login', 'nc-report': 'nc-report', 'babel-polyfill': 'babel-polyfill', 'nc-graphic-report': 'nc-graphic-report', axios: { root: 'axios', var: 'axios', commonjs: 'axios', commonjs2: 'axios', amd: 'axios' }, react: { root: 'React', var: 'React', commonjs: 'react', commonjs2: 'react', amd: 'react' }, // redux: { // root: 'Redux', // var: 'Redux', // commonjs: 'redux', // commonjs2: 'redux', // amd: 'redux' // }, // 'react-redux': { // root: 'ReactRedux', // var: 'ReactRedux', // commonjs: 'react-redux', // commonjs2: 'react-redux', // amd: 'react-redux' // }, 'react-router': { root: 'ReactRouter', var: 'ReactRouter', commonjs: 'react-router', commonjs2: 'react-router', amd: 'react-router' }, 'react-dom': { root: 'ReactDOM', var: 'ReactDOM', commonjs: 'react-dom', commonjs2: 'react-dom', amd: 'react-dom' } }, resolve: { extensions: ['.jsx', '.js', '.less', '.css', '.json'], alias: { 'src': path.resolve(__dirname, '../src/') } }, module: { rules: [{ test: /\.(jsx|js)$/, exclude: /node_modules/, use: { loader: 'happypack/loader', options: { presets: ['env', 'react'], plugins: [ ['import-bee', { "style": true }], 'transform-class-properties', 'transform-runtime', 'babel-plugin-transform-regenerator' ] } } }, { test: /\.less$/, exclude: /node_modules/, use: [ MiniCssExtractPlugin.loader, 'css-loader', 'postcss-loader', 'less-loader' ] }, { test: /\.css$/, exclude: /node_modules/, use: [ MiniCssExtractPlugin.loader, { loader: 'css-loader', options: { mode: 'local', modules: true, localIdentName: '[name]--[local]--[hash:base64:5]' } }, 'postcss-loader' ] }, { test: /\.css$/, include: /node_modules/, use: [ MiniCssExtractPlugin.loader, { loader: 'css-loader', options: { modules: false, } }, 'postcss-loader', ] }, { test: /\.(png|jpg|jpeg|gif|eot|ttf|woff|woff2|svg|svgz|xlsx)(\?.+)?$/, exclude: /favicon\.png$/, use: [{ loader: 'url-loader' }] }] }, plugins: [ new MiniCssExtractPlugin({ filename: '[name]_[hash:8].css' }), new happyPack({ loaders: ['babel-loader'], threads: 2 }), new FriendlyErrorsWebpackPlugin() ] };