Understanding r.js w / grunt & basebone options and relative paths

I am trying to figure out how to use r.js. I keep getting errors that occur in such a way that the module path does not exist, or files that are dumped where they should not be.

I have a one page application integrated with wordpress. I accepted this template pattern for my overall structure, although I installed a completely different one. Below is my file structure.

.Theme Folder
β”œβ”€β”€ _assets
|   β”œβ”€β”€ _application
|   |   β”œβ”€β”€ css
|   |   β”œβ”€β”€ fonts
|   |   β”œβ”€β”€ img
|   |   β”œβ”€β”€ _js
|   |   |   β”œβ”€β”€ main.js  //this is my require.js config file
|   |   |   β”œβ”€β”€ _app  //here where the boilerplate structure comes into play
|   |   |       β”œβ”€β”€ collections
|   |   |       β”œβ”€β”€ models
|   |   |       β”œβ”€β”€ routers
|   |   |       β”œβ”€β”€ templates
|   |   |       β”œβ”€β”€ views
|   |   |   β”œβ”€β”€ libs
|   |   |   β”œβ”€β”€ utilities
|   |   β”œβ”€β”€ scss
|   |   β”œβ”€β”€ video
|   └── build  //Concatenated application directory mirror
|   └── gruntfile.js
|   └── bower.json
|   └── package.json

grunt. , conatenated, . r.js, . , lodash ( main.js). , lodash /lodash.js, baseUrl main.js(configuration.js). - /application/js/libs/lodash.js. requirejs :

        requirejs: {
          compile: {
            options: {
              baseUrl: "./",
              mainConfigFile: "application/js/main.js",
              name: "./application/js/main",
              out: "./build/js/optimized.js"
            }
          }
        }

, rjs. , , . , ... - , r.js, .

, :

>> Error: ENOENT, no such file or directory
>> 'path-to-theme-folder-here/assets/libs/lodash.js'
>> In module tree:
>>     application/js/main.min
+2
1

, , :

requirejs: {
  compile: {
    options: {
      baseUrl: "application/js/",
      mainConfigFile: "application/js/main.js",
      name: "main",
      out: "build/js/optimized.js"
    }
  }
}
+2

Source: https://habr.com/ru/post/1628692/


All Articles