You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 6, 2024. It is now read-only.
var webpack = require('webpack');
var path = require('path');
// variables
var isProduction = process.argv.indexOf('-p') >= 0 || process.env.NODE_ENV === 'production';
var sourcePath = path.join(__dirname, './src');
var outPath = path.join(__dirname, './dist/static');
var appPath = path.join(sourcePath, '/app');
var commonPath = path.join(sourcePath, '/common');
var servicePath = path.join(sourcePath, '/service');
var antdPath = path.join(sourcePath, '/library/ant-design/components');
var langPath = path.join(sourcePath, '/app/assets/localLang');
var errCodeFnPath = path.join(sourcePath, '/app/utils/errCodeFn.ts');
// plugins
var HtmlWebpackPlugin = require('html-webpack-plugin');
var MiniCssExtractPlugin = require('mini-css-extract-plugin');
var WebpackCleanupPlugin = require('webpack-cleanup-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
// 配置 HappyPack
var HappyPack = require('happypack'),
os = require('os'),
happyThreadPool = HappyPack.ThreadPool({ size: os.cpus().length })
module.exports = {
context: sourcePath,
entry: {
app: './main.tsx'
},
output: {
path: outPath,
filename: 'bundle.js',
chunkFilename: '[hash]/[chunkhash].js',
publicPath: isProduction ? '/static/' : ''
},
target: 'web',
resolve: {
extensions: ['.js', '.ts', '.tsx'],
mainFields: ['module', 'browser', 'main'],
alias: {
app: appPath,
common: commonPath,
service: servicePath,
antd: antdPath,
Lang: langPath,
errCodeFn: errCodeFnPath
}
},
resolveLoader: {
modules: ['node_modules', 'tools']
},
module: {
// loaders: [
// {
// test: /.js|jsx$/,
// loader: 'HappyPack/loader?id=jsHappy',
// exclude: /node_modules/
// }
// ],
rules: [
{
test: /.tsx?$/,
use: [
isProduction && {
loader: 'babel-loader',
options: { plugins: ['react-hot-loader/babel'] }
},
'ts-loader',
{
loader: 'ui-loader',
options: {
'lib': 'antd',
'camel2': '-',
'style': 'style/index.less'
}
},
'happypack/loader'
].filter(Boolean)
},
{
test: /.less$/,
use: [
{
loader: 'style-loader'
},
{
loader: 'css-loader',
options: {
sourceMap: true,
modules: true,
localIdentName: '[local]___[hash:base64:5]'
}
},
{
loader: 'less-loader'
}
],
include: [appPath]
},
{
test: /.css$/,
use: [
{
loader: 'style-loader'
},
{
loader: 'css-loader',
options: {
modules: false
}
},
{
loader: 'less-loader'
}
],
include: [appPath]
},
{
test: /.less$/,
use: [
{
loader: 'style-loader'
},
{
loader: 'css-loader'
},
{
loader: 'less-loader',
options: {
javascriptEnabled: true
}
}
],
exclude: [appPath]
},
{ test: /.(png|svg)$/, use: 'url-loader?limit=10000' },
{ test: /.(jpg|gif)$/, use: 'file-loader' }
]
},
optimization: {
splitChunks: {
name: true,
cacheGroups: {
commons: {
chunks: 'initial',
minChunks: 2
},
vendors: {
test: /[\/]node_modules[\/]/,
chunks: 'all',
priority: -10
}
}
},
runtimeChunk: true
},
plugins: [
new webpack.EnvironmentPlugin({
NODE_ENV: 'development',
DEBUG: false
}),
new WebpackCleanupPlugin(),
new MiniCssExtractPlugin({
filename: '[contenthash].css',
disable: !isProduction
}),
new HtmlWebpackPlugin({
title: 'DuoOffice',
filename: isProduction ? '../index.html' : 'index.html',
template: 'pug-loader!src/index.jade'
}),
],
devServer: {
contentBase: sourcePath,
hot: true,
inline: true,
historyApiFallback: {
disableDotRule: true
},
disableHostCheck: true,
},
node: {
fs: 'empty',
net: 'empty'
}
};
14 |
15 | ReactDOM.render(
Child html-webpack-plugin for "../index.html":
1 asset
Entrypoint undefined = ../index.html
[0] ../node_modules/pug-loader!./index.jade 1.09 KiB {0} [built]
[2] external "fs" 42 bytes {0} [optional] [built]
+ 1 hidden module
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! [email protected] build:
webpack -p --progress --colors
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/mac/.npm/_logs/2018-09-12T13_10_31_200Z-debug.log
The text was updated successfully, but these errors were encountered: