Last active
July 21, 2018 08:55
-
-
Save terrierscript/70055dfc83f2b500835e to your computer and use it in GitHub Desktop.
javascriptビルドツールなどで相対パス地獄(../../)を解決する方法まとめ ref: https://qiita.com/terrierscript/items/daa9cd33f3adaf72db68
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| . | |
| └── src | |
| ├── foo | |
| │ └── baz.js | |
| └── index.js |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import baz from "foo/baz" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module.exports = { | |
| entry: "./src/index.js", | |
| // resolve.rootで指定 | |
| resolve: { | |
| root: [ | |
| path.join(__dirname, "./src") | |
| ] | |
| }, | |
| module: { | |
| loaders: [ | |
| { | |
| test: /^src\/.*\.js$/, | |
| include: [ | |
| path.resolve(__dirname, "src"), | |
| ], | |
| loader: "babel-loader" | |
| } | |
| ] | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| NODE_PATH=./some/lib browserify -e src/index.js -o build/index.js |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| browserify("src/index.js", { | |
| paths:[ | |
| "./node_module", "./src" | |
| ] | |
| }).bundle(function(err, out){ | |
| // out.toStirng() とかでコード取れる | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import includePaths from 'rollup-plugin-includepaths'; | |
| let includePathOptions = { | |
| include: {}, | |
| paths: ['src'], | |
| }; | |
| export default { | |
| entry: './src/index.js', | |
| dest: 'build/index.js', | |
| plugins: [ includePaths(includePathOptions) ], | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| NODE_PATH=src/ mocha ./test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| NODE_PATH=src/ ava ./test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "baseUrl": "./src" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [options] | |
| module.system.node.resolve_dirname=./node_modules | |
| module.system.node.resolve_dirname=./src |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment