diff --git a/demo/scripts/build.js b/demo/scripts/build.js index ca20b3d75..f066877ba 100644 --- a/demo/scripts/build.js +++ b/demo/scripts/build.js @@ -1,3 +1,4 @@ +import fs from "fs" import path from "path" import webpack from "webpack" import ExtractTextPlugin from "extract-text-webpack-plugin" @@ -180,6 +181,11 @@ builder({ target: "node", + externals: [ + ...fs.readdirSync("node_modules").filter((x) => x !== ".bin"), + "statinamic/lib/md-collection-loader/cache", + ], + output: { ...webpackConfig.output, libraryTarget: "commonjs2", diff --git a/demo/web_modules/app/store.js b/demo/web_modules/app/store.js index bf2695e81..86c121d2a 100644 --- a/demo/web_modules/app/store.js +++ b/demo/web_modules/app/store.js @@ -1,6 +1,7 @@ import { combineReducers } from "redux" import createStore from "statinamic/lib/redux/createStore" import * as statinamicReducers from "statinamic/lib/redux/modules" +import minifyCollection from "statinamic/lib/md-collection-loader/minify" import * as pageComponents from "app/pageComponents" @@ -14,10 +15,11 @@ const store = createStore( // static build optimization ...__PROD__ && { collection: - require("statinamic/lib/md-collection-loader/cache").default, + minifyCollection(require("statinamic/lib/md-collection-loader/cache")), }, pageComponents, } ) + export default store diff --git a/src/boilerplate/scripts/build.js b/src/boilerplate/scripts/build.js index f0e1c1ef7..34efaa1dd 100644 --- a/src/boilerplate/scripts/build.js +++ b/src/boilerplate/scripts/build.js @@ -1,3 +1,4 @@ +import fs from "fs" import path from "path" import webpack from "webpack" import ExtractTextPlugin from "extract-text-webpack-plugin" @@ -177,6 +178,11 @@ builder({ target: "node", + externals: [ + ...fs.readdirSync("node_modules").filter((x) => x !== ".bin"), + "statinamic/lib/md-collection-loader/cache", + ], + output: { ...webpackConfig.output, libraryTarget: "commonjs2", diff --git a/src/boilerplate/web_modules/app/store.js b/src/boilerplate/web_modules/app/store.js index bf2695e81..86c121d2a 100644 --- a/src/boilerplate/web_modules/app/store.js +++ b/src/boilerplate/web_modules/app/store.js @@ -1,6 +1,7 @@ import { combineReducers } from "redux" import createStore from "statinamic/lib/redux/createStore" import * as statinamicReducers from "statinamic/lib/redux/modules" +import minifyCollection from "statinamic/lib/md-collection-loader/minify" import * as pageComponents from "app/pageComponents" @@ -14,10 +15,11 @@ const store = createStore( // static build optimization ...__PROD__ && { collection: - require("statinamic/lib/md-collection-loader/cache").default, + minifyCollection(require("statinamic/lib/md-collection-loader/cache")), }, pageComponents, } ) + export default store