about summary refs log tree commit diff
path: root/config/webpack/shared.js
diff options
context:
space:
mode:
authorYamagishi Kazutoshi <ykzts@desire.sh>2017-06-18 09:57:09 +0900
committerEugen Rochko <eugen@zeonfederated.com>2017-06-18 02:57:09 +0200
commit53e42bf91ef2c705168f8d04b9374c349ec14074 (patch)
tree564d8607ee6fd7ac27979d157b261c038e9fad61 /config/webpack/shared.js
parent94d0e012dea89058b9c059636fb6d42f6565e534 (diff)
Upgrade Webpacker to version 2.0 (#3729)
Diffstat (limited to 'config/webpack/shared.js')
-rw-r--r--config/webpack/shared.js32
1 files changed, 18 insertions, 14 deletions
diff --git a/config/webpack/shared.js b/config/webpack/shared.js
index de57ecb68..4d865b816 100644
--- a/config/webpack/shared.js
+++ b/config/webpack/shared.js
@@ -7,21 +7,22 @@ const { sync } = require('glob');
 const ExtractTextPlugin = require('extract-text-webpack-plugin');
 const ManifestPlugin = require('webpack-manifest-plugin');
 const extname = require('path-complete-extname');
-const { env, paths, publicPath, loadersDir } = require('./configuration.js');
+const { env, settings, output, loadersDir } = require('./configuration.js');
 const localePackPaths = require('./generateLocalePacks');
 
-const extensionGlob = `**/*{${paths.extensions.join(',')}}*`;
-const packPaths = sync(join(paths.source, paths.entry, extensionGlob));
-const entryPacks = [].concat(packPaths).concat(localePackPaths).filter(path => path !== join(paths.source, paths.entry, 'custom.js'));
+const extensionGlob = `**/*{${settings.extensions.join(',')}}*`;
+const entryPath = join(settings.source_path, settings.source_entry_path);
+const packPaths = sync(join(entryPath, extensionGlob));
+const entryPacks = [...packPaths, ...localePackPaths].filter(path => path !== join(entryPath, 'custom.js'));
 
-const customApplicationStyle = resolve(join(paths.source, 'styles/custom.scss'));
-const originalApplicationStyle = resolve(join(paths.source, 'styles/application.scss'));
+const customApplicationStyle = resolve(join(settings.source_path, 'styles/custom.scss'));
+const originalApplicationStyle = resolve(join(settings.source_path, 'styles/application.scss'));
 
 module.exports = {
   entry: entryPacks.reduce(
     (map, entry) => {
       const localMap = map;
-      let namespace = relative(join(paths.source, paths.entry), dirname(entry));
+      let namespace = relative(join(entryPath), dirname(entry));
       if (namespace === join('..', '..', '..', 'tmp', 'packs')) {
         namespace = ''; // generated by generateLocalePacks.js
       }
@@ -33,8 +34,8 @@ module.exports = {
   output: {
     filename: '[name].js',
     chunkFilename: '[name]-[chunkhash].js',
-    path: resolve(paths.output, paths.entry),
-    publicPath,
+    path: output.path,
+    publicPath: output.publicPath,
   },
 
   module: {
@@ -44,7 +45,10 @@ module.exports = {
   plugins: [
     new webpack.EnvironmentPlugin(JSON.parse(JSON.stringify(env))),
     new ExtractTextPlugin(env.NODE_ENV === 'production' ? '[name]-[hash].css' : '[name].css'),
-    new ManifestPlugin({ fileName: paths.manifest, publicPath, writeToFileEmit: true }),
+    new ManifestPlugin({
+      publicPath: output.publicPath,
+      writeToFileEmit: true,
+    }),
     new webpack.optimize.CommonsChunkPlugin({
       name: 'common',
       minChunks: (module, count) => {
@@ -67,15 +71,15 @@ module.exports = {
       'mastodon-application-style': existsSync(customApplicationStyle) ?
                                     customApplicationStyle : originalApplicationStyle,
     },
-    extensions: paths.extensions,
+    extensions: settings.extensions,
     modules: [
-      resolve(paths.source),
-      resolve(paths.node_modules),
+      resolve(settings.source_path),
+      'node_modules',
     ],
   },
 
   resolveLoader: {
-    modules: [paths.node_modules],
+    modules: ['node_modules'],
   },
 
   node: {