Skip to content
Snippets Groups Projects
Commit dc867bad authored by netpro2k's avatar netpro2k
Browse files

Revert merge issue with webpack.config.js

parent 40435169
No related branches found
No related tags found
No related merge requests found
......@@ -9,7 +9,6 @@ const HTMLWebpackPlugin = require("html-webpack-plugin");
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
const _ = require("lodash");
function createHTTPSConfig() {
// Generate certs for the local webpack-dev-server.
......@@ -58,21 +57,6 @@ function createHTTPSConfig() {
}
}
class LodashTemplatePlugin {
constructor(options) {
this.options = options;
}
apply(compiler) {
compiler.plugin("compilation", compilation => {
compilation.plugin("html-webpack-plugin-before-html-processing", async data => {
data.html = _.template(data.html, this.options)();
return data;
});
});
}
}
module.exports = (env, argv) => ({
entry: {
index: path.join(__dirname, "src", "index.js"),
......@@ -118,9 +102,7 @@ module.exports = (env, argv) => ({
loader: "html-loader",
options: {
// <a-asset-item>'s src property is overwritten with the correct transformed asset url.
attrs: ["img:src", "a-asset-item:src", "audio:src", "source:src"],
// You can get transformed asset urls in an html template using ${require("pathToFile.ext")}
interpolate: "require"
attrs: ["img:src", "a-asset-item:src", "audio:src", "source:src"]
}
},
{
......@@ -187,33 +169,57 @@ module.exports = (env, argv) => ({
}
]
},
// necessary due to https://github.com/visionmedia/debug/issues/547
optimization: {
minimizer: [new UglifyJsPlugin({ uglifyOptions: { compress: { collapse_vars: false } } })]
// necessary due to https://github.com/visionmedia/debug/issues/547
minimizer: [new UglifyJsPlugin({ uglifyOptions: { compress: { collapse_vars: false } } })],
splitChunks: {
cacheGroups: {
engine: {
test: /[\\/]node_modules[\\/](aframe|cannon|three\.js)/,
priority: 100,
name: "engine",
chunks: "all"
},
vendors: {
test: /([\\/]node_modules[\\/]|[\\/]vendor[\\/])/,
priority: 50,
name: "vendor",
chunks: "all"
}
}
}
},
plugins: [
// Each output page needs a HTMLWebpackPlugin entry
new HTMLWebpackPlugin({
filename: "index.html",
template: path.join(__dirname, "src", "index.html"),
// Chunks correspond with the entries you wish to include in your html template
chunks: ["index"]
chunks: ["vendor", "index"]
}),
new HTMLWebpackPlugin({
filename: "hub.html",
template: path.join(__dirname, "src", "hub.html"),
chunks: ["hub"],
inject: "head"
chunks: ["vendor", "engine", "hub"],
inject: "head",
meta: [
{
"http-equiv": "origin-trial",
"data-feature": "WebVR (For Chrome M62+)",
"data-expires": process.env.ORIGIN_TRIAL_EXPIRES,
content: process.env.ORIGIN_TRIAL_TOKEN
}
]
}),
new HTMLWebpackPlugin({
filename: "link.html",
template: path.join(__dirname, "src", "link.html"),
chunks: ["link"]
chunks: ["vendor", "link"]
}),
new HTMLWebpackPlugin({
filename: "avatar-selector.html",
template: path.join(__dirname, "src", "avatar-selector.html"),
chunks: ["avatar-selector"],
chunks: ["vendor", "engine", "avatar-selector"],
inject: "head"
}),
new CopyWebpackPlugin([
......@@ -233,17 +239,6 @@ module.exports = (env, argv) => ({
filename: "assets/stylesheets/[name]-[md5:contenthash:hex:20].css",
disable: argv.mode !== "production"
}),
// Transform the output of the html-loader using _.template
// before passing the result to html-webpack-plugin
new LodashTemplatePlugin({
// expose these variables to the lodash template
// ex: <%= ORIGIN_TRIAL_TOKEN %>
imports: {
NODE_ENV: argv.mode,
ORIGIN_TRIAL_EXPIRES: process.env.ORIGIN_TRIAL_EXPIRES,
ORIGIN_TRIAL_TOKEN: process.env.ORIGIN_TRIAL_TOKEN
}
}),
// Define process.env variables in the browser context.
new webpack.DefinePlugin({
"process.env": JSON.stringify({
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment