Monday, 25 March 2019

webpack, restrict what can be imported

Is there a way in webpack to restrict what files can be imported?

Say I want to be able to import files that are in the same directory, as well as the parent directory, but nothing above that parent directory? For example:

These work

import blah from "./script.js";

import blah2 from "./../gui/textbox.js";

import blah3 from  "./../I/can/go/as/deep/down/as/I/want/here.js";

But this wouldn't work

import "./../../passwords.txt";

Because that would go up two (or x number of) directories, instead of just one.



from webpack, restrict what can be imported

No comments:

Post a Comment