-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e116906
commit b5a30fc
Showing
4 changed files
with
65 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,76 @@ | ||
import path, {join, resolve} from 'path' | ||
import { aliasItems, devServerUrl, externalItems } from './config' | ||
import {aliasItems, devServerUrl, externalItems} from './config' | ||
import entry from './entry' | ||
import { rootDir } from './utils/env' | ||
import {rootDir} from './utils/env' | ||
import optimization from './optimization' | ||
import * as plugins from './plugins' | ||
import * as rules from './rules' | ||
import { isDevServer, isProd } from './utils/env' | ||
import { arrayFilterEmpty } from './utils/helpers' | ||
import {isDevServer, isProd} from './utils/env' | ||
import {arrayFilterEmpty} from './utils/helpers' | ||
|
||
const runtime = process.env.RUNTIME | ||
const isWeb = runtime === 'web' | ||
const buildPath = process.env.BUILD_PATH || 'src/build'; | ||
|
||
|
||
export default { | ||
context: __dirname, | ||
target: isWeb ? 'browserslist' : 'electron-renderer', | ||
mode: isProd ? 'production' : 'development', | ||
entry, | ||
output: { | ||
path: resolve(join(rootDir, buildPath)), | ||
publicPath: isDevServer ? devServerUrl : './', | ||
filename: isDevServer | ||
? '[name].[fullhash].js' | ||
: '[name].[contenthash].js' | ||
}, | ||
module: { | ||
strictExportPresence: true, | ||
rules: arrayFilterEmpty([ | ||
rules.javascriptRule, | ||
rules.typescriptRule, | ||
rules.htmlRule, | ||
rules.imagesRule, | ||
rules.fontsRule, | ||
rules.cssRule, | ||
rules.sassRule, | ||
...rules.svgRules | ||
]) | ||
}, | ||
plugins: arrayFilterEmpty([ | ||
plugins.htmlWebpackPlugin, | ||
plugins.providePlugin, | ||
plugins.definePlugin, | ||
plugins.nodePolyfillPlugin, | ||
plugins.copyPlugin, | ||
...(isProd && [plugins.workBoxSW] || []) | ||
]), | ||
resolve: { | ||
modules: [ | ||
"node_modules", | ||
path.resolve(__dirname) | ||
], | ||
alias: aliasItems, | ||
extensions: ['.js', '.jsx', '.css', '.json', '.scss'], | ||
fallback: { | ||
stream: require.resolve("stream-browserify"), | ||
fs: false | ||
} | ||
}, | ||
node: { | ||
global: true, | ||
__dirname: true, | ||
__filename: true | ||
}, | ||
optimization, | ||
externals: externalItems, | ||
devtool: 'inline-source-map', | ||
context: __dirname, | ||
target: isWeb ? 'browserslist' : 'electron-renderer', | ||
mode: isProd ? 'production' : 'development', | ||
entry, | ||
output: { | ||
path: resolve(join(rootDir, buildPath)), | ||
publicPath: isDevServer ? devServerUrl : './', | ||
filename: isDevServer | ||
? '[name].[fullhash].js' | ||
: '[name].[contenthash].js' | ||
}, | ||
module: { | ||
strictExportPresence: true, | ||
rules: arrayFilterEmpty([ | ||
rules.javascriptRule, | ||
rules.typescriptRule, | ||
rules.htmlRule, | ||
rules.imagesRule, | ||
rules.fontsRule, | ||
rules.cssRule, | ||
rules.sassRule, | ||
...rules.svgRules | ||
]) | ||
}, | ||
plugins: arrayFilterEmpty([ | ||
plugins.htmlWebpackPlugin, | ||
plugins.providePlugin, | ||
plugins.definePlugin, | ||
plugins.nodePolyfillPlugin, | ||
plugins.copyPlugin, | ||
...(isProd && [plugins.workBoxSW] || []) | ||
]), | ||
resolve: { | ||
modules: [ | ||
"node_modules", | ||
path.resolve(__dirname) | ||
], | ||
alias: aliasItems, | ||
extensions: ['.js', '.jsx', '.css', '.json', '.scss'], | ||
fallback: { | ||
stream: require.resolve("stream-browserify"), | ||
module: false, | ||
dgram: false, | ||
dns: 'mock', | ||
fs: false, | ||
http2: false, | ||
net: false, | ||
tls: false, | ||
child_process: false, | ||
} | ||
}, | ||
node: { | ||
global: true, | ||
__dirname: true, | ||
__filename: true | ||
}, | ||
optimization, | ||
externals: externalItems, | ||
devtool: 'inline-source-map', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters