Bläddra i källkod

update path settings for webpack

Yuki Takei 4 år sedan
förälder
incheckning
4852e18cc1

+ 48 - 50
packages/app/config/webpack.common.js

@@ -1,56 +1,55 @@
 /**
  * @author: Yuki Takei <yuki@weseek.co.jp>
  */
+const path = require('path');
 const webpack = require('webpack');
 
 /*
- * Webpack Plugins
- */
+  * Webpack Plugins
+  */
 const WebpackAssetsManifest = require('webpack-assets-manifest');
 const LodashModuleReplacementPlugin = require('lodash-webpack-plugin');
 
-const helpers = require('../src/lib/util/helpers');
-
 /*
- * Webpack configuration
- *
- * See: http://webpack.github.io/docs/configuration.html#cli
- */
+  * Webpack configuration
+  *
+  * See: http://webpack.github.io/docs/configuration.html#cli
+  */
 module.exports = (options) => {
   return {
     mode: options.mode,
     entry: Object.assign({
-      'js/boot':                      './src/client/js/boot',
-      'js/app':                       './src/client/js/app',
-      'js/admin':                     './src/client/js/admin',
-      'js/nologin':                   './src/client/js/nologin',
-      'js/legacy':                    './src/client/js/legacy/crowi',
-      'js/legacy-presentation':       './src/client/js/legacy/crowi-presentation',
-      'js/plugin':                    './src/client/js/plugin',
-      'js/ie11-polyfill':             './src/client/js/ie11-polyfill',
-      'js/hackmd-agent':              './src/client/js/hackmd-agent',
-      'js/hackmd-styles':             './src/client/js/hackmd-styles',
+      'js/boot':                      './src/client/boot',
+      'js/app':                       './src/client/app',
+      'js/admin':                     './src/client/admin',
+      'js/nologin':                   './src/client/nologin',
+      'js/legacy':                    './src/client/legacy/crowi',
+      'js/legacy-presentation':       './src/client/legacy/crowi-presentation',
+      'js/plugin':                    './src/client/plugin',
+      'js/ie11-polyfill':             './src/client/ie11-polyfill',
+      'js/hackmd-agent':              './src/client/hackmd-agent',
+      'js/hackmd-styles':             './src/client/hackmd-styles',
       // styles
-      'styles/style-app':             './src/client/styles/scss/style-app.scss',
-      'styles/style-presentation':    './src/client/styles/scss/style-presentation.scss',
+      'styles/style-app':             './src/styles/style-app.scss',
+      'styles/style-presentation':    './src/styles/style-presentation.scss',
       // themes
-      'styles/theme-default':         './src/client/styles/scss/theme/default.scss',
-      'styles/theme-nature':          './src/client/styles/scss/theme/nature.scss',
-      'styles/theme-mono-blue':       './src/client/styles/scss/theme/mono-blue.scss',
-      'styles/theme-future':          './src/client/styles/scss/theme/future.scss',
-      'styles/theme-kibela':          './src/client/styles/scss/theme/kibela.scss',
-      'styles/theme-halloween':       './src/client/styles/scss/theme/halloween.scss',
-      'styles/theme-christmas':          './src/client/styles/scss/theme/christmas.scss',
-      'styles/theme-wood':          './src/client/styles/scss/theme/wood.scss',
-      'styles/theme-island':      './src/client/styles/scss/theme/island.scss',
-      'styles/theme-antarctic':      './src/client/styles/scss/theme/antarctic.scss',
-      'styles/theme-spring':         './src/client/styles/scss/theme/spring.scss',
-      'styles/theme-hufflepuff':         './src/client/styles/scss/theme/hufflepuff.scss',
+      'styles/theme-default':         './src/styles/theme/default.scss',
+      'styles/theme-nature':          './src/styles/theme/nature.scss',
+      'styles/theme-mono-blue':       './src/styles/theme/mono-blue.scss',
+      'styles/theme-future':          './src/styles/theme/future.scss',
+      'styles/theme-kibela':          './src/styles/theme/kibela.scss',
+      'styles/theme-halloween':       './src/styles/theme/halloween.scss',
+      'styles/theme-christmas':       './src/styles/theme/christmas.scss',
+      'styles/theme-wood':            './src/styles/theme/wood.scss',
+      'styles/theme-island':          './src/styles/theme/island.scss',
+      'styles/theme-antarctic':       './src/styles/theme/antarctic.scss',
+      'styles/theme-spring':          './src/styles/theme/spring.scss',
+      'styles/theme-hufflepuff':      './src/styles/theme/hufflepuff.scss',
       // styles for external services
-      'styles/style-hackmd':          './src/client/styles/hackmd/style.scss',
+      'styles/style-hackmd':          './src/styles-hackmd/style.scss',
     }, options.entry || {}), // Merge with env dependent settings
     output: Object.assign({
-      path: helpers.root('public'),
+      path: path.resolve(__dirname, '../public'),
       publicPath: '/',
       filename: '[name].bundle.js',
     }, options.output || {}), // Merge with env dependent settings
@@ -62,16 +61,15 @@ module.exports = (options) => {
       hljs: 'hljs',
     },
     resolve: {
-      extensions: ['.js', '.jsx', '.json'],
-      modules: ((options.resolve && options.resolve.modules) || []).concat([helpers.root('node_modules')]),
+      extensions: ['.js', '.jsx', '.ts', '.tsx', '.json'],
+      // modules: ((options.resolve && options.resolve.modules) || []).concat([path.resolve(__dirname, 'node_modules')]),
       alias: {
-        '@root': helpers.root('/'),
-        '@commons': helpers.root('src/lib'),
-        '@client': helpers.root('src/client'),
-        '@tmp': helpers.root('tmp'),
-        '@alias/logger': helpers.root('src/lib/service/logger'),
-        // replace bunyan
-        bunyan: 'browser-bunyan',
+        '~': path.resolve(__dirname, '../src'), // src
+        '^': path.resolve(__dirname, '../'), // project root
+        '@root': path.resolve(__dirname, '../'),
+        '@commons': path.resolve(__dirname, '../src/lib'),
+        '@client': path.resolve(__dirname, '../src/client'),
+        '@alias/logger': path.resolve(__dirname, '../src/utils/logger'),
       },
     },
     module: {
@@ -79,11 +77,11 @@ module.exports = (options) => {
         {
           test: /.jsx?$/,
           exclude: {
-            test:    helpers.root('node_modules'),
+            test: path.resolve(__dirname, '../node_modules'),
             exclude: [ // include as a result
-              { test: helpers.root('node_modules', 'growi-plugin-') },
-              helpers.root('node_modules/growi-commons'),
-              helpers.root('node_modules/codemirror/src'),
+              { test: path.resolve(__dirname, '../node_modules/growi-plugin-') },
+              path.resolve(__dirname, '../node_modules/growi-commons'),
+              path.resolve(__dirname, '../node_modules/codemirror/src'),
             ],
           },
           use: [{
@@ -98,14 +96,14 @@ module.exports = (options) => {
           },
         },
         /*
-         * File loader for supporting images, for example, in CSS files.
-         */
+          * File loader for supporting images, for example, in CSS files.
+          */
         {
           test: /\.(jpg|png|gif)$/,
           use: 'file-loader',
         },
         /* File loader for supporting fonts, for example, in CSS files.
-        */
+         */
         {
           test: /\.(eot|woff2?|svg|ttf)([?]?.*)$/,
           use: 'null-loader',

+ 9 - 9
packages/app/config/webpack.prod.js

@@ -2,19 +2,19 @@
  * @author: Yuki Takei <yuki@weseek.co.jp>
  */
 
+const path = require('path');
+
 /**
- * Webpack Plugins
- */
+  * Webpack Plugins
+  */
 const TerserPlugin = require('terser-webpack-plugin');
 const MiniCssExtractPlugin = require('mini-css-extract-plugin');
 const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
 const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
 
-const helpers = require('../src/lib/util/helpers');
-
 /**
- * Webpack Constants
- */
+  * Webpack Constants
+  */
 const { ANALYZE } = process.env;
 
 module.exports = require('./webpack.common')({
@@ -44,12 +44,12 @@ module.exports = require('./webpack.common')({
           },
           'sass-loader',
         ],
-        exclude: [helpers.root('src/client/js/legacy')],
+        exclude: [path.resolve(__dirname, '../src/client/legacy')],
       },
       {
         test: /\.(css|scss)$/,
         use: ['style-loader', 'css-loader', 'sass-loader'],
-        include: [helpers.root('src/client/js/legacy')],
+        include: [path.resolve(__dirname, '../src/client/legacy')],
       },
     ],
   },
@@ -61,7 +61,7 @@ module.exports = require('./webpack.common')({
 
     new BundleAnalyzerPlugin({
       analyzerMode: ANALYZE ? 'static' : 'disabled',
-      reportFilename: helpers.root('report/bundle-analyzer.html'),
+      reportFilename: path.resolve(__dirname, '../report/bundle-analyzer.html'),
       openAnalyzer: false,
     }),
 

+ 19 - 19
packages/app/src/client/admin.jsx

@@ -3,27 +3,27 @@ import ReactDOM from 'react-dom';
 import { Provider } from 'unstated';
 import { I18nextProvider } from 'react-i18next';
 
-import loggerFactory from '@alias/logger';
+import loggerFactory from '~/utils/logger';
 
-import ErrorBoundary from './components/ErrorBoudary';
+import ErrorBoundary from '../components/ErrorBoudary';
 
-import AdminHome from './components/Admin/AdminHome/AdminHome';
-import UserGroupDetailPage from './components/Admin/UserGroupDetail/UserGroupDetailPage';
-import NotificationSetting from './components/Admin/Notification/NotificationSetting';
-import SlackIntegrationNotificationSetting from './components/Admin/Notification/SlackIntegrationNotificationSetting';
-import SlackIntegration from './components/Admin/SlackIntegration/SlackIntegration';
-import ManageGlobalNotification from './components/Admin/Notification/ManageGlobalNotification';
-import MarkdownSetting from './components/Admin/MarkdownSetting/MarkDownSetting';
-import UserManagement from './components/Admin/UserManagement';
-import AppSettingsPage from './components/Admin/App/AppSettingsPage';
-import SecurityManagement from './components/Admin/Security/SecurityManagement';
-import ManageExternalAccount from './components/Admin/ManageExternalAccount';
-import UserGroupPage from './components/Admin/UserGroup/UserGroupPage';
-import Customize from './components/Admin/Customize/Customize';
-import ImportDataPage from './components/Admin/ImportDataPage';
-import ExportArchiveDataPage from './components/Admin/ExportArchiveDataPage';
-import FullTextSearchManagement from './components/Admin/FullTextSearchManagement';
-import AdminNavigation from './components/Admin/Common/AdminNavigation';
+import AdminHome from '../components/Admin/AdminHome/AdminHome';
+import UserGroupDetailPage from '../components/Admin/UserGroupDetail/UserGroupDetailPage';
+import NotificationSetting from '../components/Admin/Notification/NotificationSetting';
+import SlackIntegrationNotificationSetting from '../components/Admin/Notification/SlackIntegrationNotificationSetting';
+import SlackIntegration from '../components/Admin/SlackIntegration/SlackIntegration';
+import ManageGlobalNotification from '../components/Admin/Notification/ManageGlobalNotification';
+import MarkdownSetting from '../components/Admin/MarkdownSetting/MarkDownSetting';
+import UserManagement from '../components/Admin/UserManagement';
+import AppSettingsPage from '../components/Admin/App/AppSettingsPage';
+import SecurityManagement from '../components/Admin/Security/SecurityManagement';
+import ManageExternalAccount from '../components/Admin/ManageExternalAccount';
+import UserGroupPage from '../components/Admin/UserGroup/UserGroupPage';
+import Customize from '../components/Admin/Customize/Customize';
+import ImportDataPage from '../components/Admin/ImportDataPage';
+import ExportArchiveDataPage from '../components/Admin/ExportArchiveDataPage';
+import FullTextSearchManagement from '../components/Admin/FullTextSearchManagement';
+import AdminNavigation from '../components/Admin/Common/AdminNavigation';
 
 import NavigationContainer from './services/NavigationContainer';
 

+ 34 - 34
packages/app/src/client/app.jsx

@@ -3,40 +3,40 @@ import ReactDOM from 'react-dom';
 import { Provider } from 'unstated';
 import { I18nextProvider } from 'react-i18next';
 
-import loggerFactory from '@alias/logger';
-
-import ErrorBoundary from './components/ErrorBoudary';
-import Sidebar from './components/Sidebar';
-import SearchPage from './components/SearchPage';
-import TagsList from './components/TagsList';
-import DisplaySwitcher from './components/Page/DisplaySwitcher';
-import { defaultEditorOptions, defaultPreviewOptions } from './components/PageEditor/OptionsSelector';
-import Page from './components/Page';
-import PageComments from './components/PageComments';
-import PageContentFooter from './components/PageContentFooter';
-import PageTimeline from './components/PageTimeline';
-import CommentEditorLazyRenderer from './components/PageComment/CommentEditorLazyRenderer';
-import PageManagement from './components/Page/PageManagement';
-import ShareLinkAlert from './components/Page/ShareLinkAlert';
-import DuplicatedAlert from './components/Page/DuplicatedAlert';
-import RedirectedAlert from './components/Page/RedirectedAlert';
-import RenamedAlert from './components/Page/RenamedAlert';
-import TrashPageList from './components/TrashPageList';
-import TrashPageAlert from './components/Page/TrashPageAlert';
-import NotFoundPage from './components/NotFoundPage';
-import NotFoundAlert from './components/Page/NotFoundAlert';
-import ForbiddenPage from './components/ForbiddenPage';
-import PageStatusAlert from './components/PageStatusAlert';
-import RecentCreated from './components/RecentCreated/RecentCreated';
-import RecentlyCreatedIcon from './components/Icons/RecentlyCreatedIcon';
-import MyDraftList from './components/MyDraftList/MyDraftList';
-import BookmarkIcon from './components/Icons/BookmarkIcon';
-import BookmarkList from './components/PageList/BookmarkList';
-import LikerList from './components/User/LikerList';
-import Fab from './components/Fab';
-import PersonalSettings from './components/Me/PersonalSettings';
-import GrowiSubNavigation from './components/Navbar/GrowiSubNavigation';
-import GrowiSubNavigationSwitcher from './components/Navbar/GrowiSubNavigationSwitcher';
+import loggerFactory from '~/utils/logger';
+
+import ErrorBoundary from '../components/ErrorBoudary';
+import Sidebar from '../components/Sidebar';
+import SearchPage from '../components/SearchPage';
+import TagsList from '../components/TagsList';
+import DisplaySwitcher from '../components/Page/DisplaySwitcher';
+import { defaultEditorOptions, defaultPreviewOptions } from '../components/PageEditor/OptionsSelector';
+import Page from '../components/Page';
+import PageComments from '../components/PageComments';
+import PageContentFooter from '../components/PageContentFooter';
+import PageTimeline from '../components/PageTimeline';
+import CommentEditorLazyRenderer from '../components/PageComment/CommentEditorLazyRenderer';
+import PageManagement from '../components/Page/PageManagement';
+import ShareLinkAlert from '../components/Page/ShareLinkAlert';
+import DuplicatedAlert from '../components/Page/DuplicatedAlert';
+import RedirectedAlert from '../components/Page/RedirectedAlert';
+import RenamedAlert from '../components/Page/RenamedAlert';
+import TrashPageList from '../components/TrashPageList';
+import TrashPageAlert from '../components/Page/TrashPageAlert';
+import NotFoundPage from '../components/NotFoundPage';
+import NotFoundAlert from '../components/Page/NotFoundAlert';
+import ForbiddenPage from '../components/ForbiddenPage';
+import PageStatusAlert from '../components/PageStatusAlert';
+import RecentCreated from '../components/RecentCreated/RecentCreated';
+import RecentlyCreatedIcon from '../components/Icons/RecentlyCreatedIcon';
+import MyDraftList from '../components/MyDraftList/MyDraftList';
+import BookmarkIcon from '../components/Icons/BookmarkIcon';
+import BookmarkList from '../components/PageList/BookmarkList';
+import LikerList from '../components/User/LikerList';
+import Fab from '../components/Fab';
+import PersonalSettings from '../components/Me/PersonalSettings';
+import GrowiSubNavigation from '../components/Navbar/GrowiSubNavigation';
+import GrowiSubNavigationSwitcher from '../components/Navbar/GrowiSubNavigationSwitcher';
 
 import NavigationContainer from './services/NavigationContainer';
 import PageContainer from './services/PageContainer';

+ 5 - 5
packages/app/src/client/base.jsx

@@ -1,15 +1,15 @@
 import React from 'react';
 
-import loggerFactory from '@alias/logger';
 import Xss from '@commons/service/xss';
+import loggerFactory from '~/utils/logger';
 
-import GrowiNavbar from './components/Navbar/GrowiNavbar';
-import GrowiNavbarBottom from './components/Navbar/GrowiNavbarBottom';
-import HotkeysManager from './components/Hotkeys/HotkeysManager';
+import GrowiNavbar from '../components/Navbar/GrowiNavbar';
+import GrowiNavbarBottom from '../components/Navbar/GrowiNavbarBottom';
+import HotkeysManager from '../components/Hotkeys/HotkeysManager';
+import PageCreateModal from '../components/PageCreateModal';
 
 import AppContainer from './services/AppContainer';
 import SocketIoContainer from './services/SocketIoContainer';
-import PageCreateModal from './components/PageCreateModal';
 
 const logger = loggerFactory('growi:cli:app');
 

+ 2 - 2
packages/app/src/client/nologin.jsx

@@ -7,8 +7,8 @@ import { i18nFactory } from './util/i18n';
 
 import AppContainer from './services/AppContainer';
 
-import InstallerForm from './components/InstallerForm';
-import LoginForm from './components/LoginForm';
+import InstallerForm from '../components/InstallerForm';
+import LoginForm from '../components/LoginForm';
 
 const i18n = i18nFactory();
 

+ 1 - 1
packages/app/src/client/plugin.js

@@ -16,7 +16,7 @@ export default class GrowiPlugin {
     // import plugin definitions
     let definitions = [];
     try {
-      definitions = require('@tmp/plugins/plugin-definitions');
+      definitions = require('^/tmp/plugins/plugin-definitions');
     }
     catch (e) {
       logger.error('failed to load definitions');