chore: move webpack.config.ts

pull/13/head
moonrailgun 4 years ago
parent d29d51a3cd
commit 021b1906f9

@ -17,11 +17,11 @@ import WorkboxPlugin from 'workbox-webpack-plugin';
require('dotenv').config(); require('dotenv').config();
delete process.env.TS_NODE_PROJECT; // https://github.com/dividab/tsconfig-paths-webpack-plugin/issues/32 delete process.env.TS_NODE_PROJECT; // https://github.com/dividab/tsconfig-paths-webpack-plugin/issues/32
require('../build/script/buildPublicTranslation.js'); // 编译前先执行一下构建翻译的脚本 require('../../build/script/buildPublicTranslation.js'); // 编译前先执行一下构建翻译的脚本
// eslint-disable-next-line @typescript-eslint/no-var-requires // eslint-disable-next-line @typescript-eslint/no-var-requires
const packageJson = require('./package.json'); const packageJson = require('../package.json');
const ROOT_PATH = path.resolve(__dirname, './'); const ROOT_PATH = path.resolve(__dirname, '../');
const DIST_PATH = path.resolve(ROOT_PATH, './dist'); const DIST_PATH = path.resolve(ROOT_PATH, './dist');
const ASSET_PATH = process.env.ASSET_PATH || '/'; const ASSET_PATH = process.env.ASSET_PATH || '/';
const PORT = Number(process.env.PORT || 11011); const PORT = Number(process.env.PORT || 11011);
@ -40,7 +40,7 @@ const mode = isDev ? 'development' : 'production';
const config: Configuration = { const config: Configuration = {
mode, mode,
entry: { entry: {
app: './src/index.tsx', app: path.resolve(ROOT_PATH, './src/index.tsx'),
}, },
output: { output: {
path: DIST_PATH, path: DIST_PATH,
@ -51,7 +51,7 @@ const config: Configuration = {
port: PORT, port: PORT,
historyApiFallback: true, historyApiFallback: true,
static: { static: {
directory: path.resolve(__dirname, './dist'), directory: path.resolve(ROOT_PATH, './dist'),
}, },
client: { client: {
overlay: false, overlay: false,
@ -66,7 +66,7 @@ const config: Configuration = {
options: { options: {
loader: 'tsx', loader: 'tsx',
target: 'es2015', target: 'es2015',
tsconfigRaw: require('./tsconfig.json'), tsconfigRaw: require('../tsconfig.json'),
}, },
}, },
{ {
@ -140,15 +140,15 @@ const config: Configuration = {
new CopyPlugin({ new CopyPlugin({
patterns: [ patterns: [
{ {
from: path.resolve(__dirname, '../locales'), from: path.resolve(ROOT_PATH, '../locales'),
to: 'locales', to: 'locales',
}, },
{ {
from: path.resolve(__dirname, './assets/pwa.webmanifest'), from: path.resolve(ROOT_PATH, './assets/pwa.webmanifest'),
to: 'pwa.webmanifest', to: 'pwa.webmanifest',
}, },
{ {
from: path.resolve(__dirname, './assets/images/logo/'), from: path.resolve(ROOT_PATH, './assets/images/logo/'),
to: 'images/logo/', to: 'images/logo/',
}, },
], ],

@ -7,8 +7,8 @@
"license": "GPLv3", "license": "GPLv3",
"private": true, "private": true,
"scripts": { "scripts": {
"build": "yarn plugins:all && cross-env TS_NODE_PROJECT='tsconfig.node.json' webpack", "build": "yarn plugins:all && cross-env TS_NODE_PROJECT='tsconfig.node.json' webpack --config ./build/webpack.config.ts",
"dev": "cross-env TS_NODE_PROJECT='tsconfig.node.json' NODE_ENV=development webpack serve", "dev": "cross-env TS_NODE_PROJECT='tsconfig.node.json' NODE_ENV=development webpack serve --config ./build/webpack.config.ts",
"serve": "npx http-server ./dist", "serve": "npx http-server ./dist",
"check:type": "tsc --noEmit --skipLibCheck", "check:type": "tsc --noEmit --skipLibCheck",
"postinstall": "node plugins/install.js", "postinstall": "node plugins/install.js",

Loading…
Cancel
Save