Comments (13)
Yes @webdiscus , thanks so much
from pug-plugin.
Hello @ltsfran,
Yes, it's possible, but currently works for Pug files only. It must works for all modules, but seems not work for styles.
I will fix this issue.
Thank you for issue report.
from pug-plugin.
Thank you, I'll try another different way
from pug-plugin.
Thank you, I'll try another different way
Later today I will release a fixed version.
from pug-plugin.
Important:
the outputPath
for pug, js and css must be under same public output path.
The public path is the root web path for server. All public assets: html, js, css must be in this public path, e.g. path.join(__dirname, 'dist/')
.
You can define paths in filename option:
const PugPlugin = require('pug-plugin');
module.exports = {
plugins: [
new PugPlugin({
filename: 'application/modules/[name].html', // => dist/application/modules/*.html,
js: {
filename: 'js/modules/[name].js', // => dist/js/modules/*.js, where * is source filename
},
css: {
filename: 'css/modules/[name].css', // => dist/css/modules/*.css, where * is source filename
// outputPath: path.join(__dirname, 'test') // WRONG path, because is outer the `dist/`
},
}),
],
};
You will define a path outer web root path, it not works:
dist/ - web root path
dist/index.html (all js and css are loaded with relative by dist/ path)
dist/css/styles.css
dist/js/scripts.js
test/ - this is outer the web root path, this path is not available in dist/index.html
from pug-plugin.
@webdiscus the problem that I have:
entries:
- pug/modules/landing/views/index.pug
- stylus/modules/landing/index.styl
- typescript/modules/landing/index.ts
output: - html/modules/landing/views/index.html
- css/modules/landing/index.css
- js/modules/landing/index.js
I want to do this, I want that directories will be dynamic.
For output directory, I've seen that webpack 5 have a hook buildCompilation, maybe I could relocate the assets files there.
from pug-plugin.
are all these files in the same directory?
public/html/modules/landing/views/index.html
public/css/modules/landing/index.css
public/js/modules/landing/index.js
then in the html/modules/landing/views/index.html
file the assets have paths:
<link href="/css/modules/landing/index.css" rel="stylesheet">
<script src="/js/modules/landing/index.js" defer="defer"></script>
It is correct?
from pug-plugin.
dynamically directories can be under same output path.
You can generate dynamically directories using the filename
as function, e.g.:
filename: (pathData) => {
const sourceFile = pathData.filename; // => /path/to/src/pages/about.pug
const relativeFile = path.relative(sourcePath, sourceFile); // => pages/about.pug
const { dir, name } = path.parse(relativeFile); // dir: 'pages', name: 'about'
return `${dir}/${name}.html`; // => dist/pages/about.html
};
from pug-plugin.
I'm going to test that. Now It works with pug files, I want to do this with .styl and .ts files
from pug-plugin.
With stylus files it doesn't work because pathData.filename doesn't exist
from pug-plugin.
update please to v4.7.0
. I have added the outputPath
property to js
and css
options.
new PugPlugin({
js: {
verbose: true, // display output info
filename: '[name].[contenthash].js',
outputPath: 'assets/js/', // relative or absolute path
},
css: {
verbose: true, // display output info
filename: '[name].[contenthash].css',
outputPath: path.join(__dirname, 'assets/css/'), // relative or absolute path
},
}),
P.S.: You can now use the js.filename
and css.filename
as function. The pathData
argument contains the filename
property (fixed in new ver).
from pug-plugin.
Thanks so much, Now I can access to filename property for my css files.
from pug-plugin.
is your problem solved? Can be closed the issue?
from pug-plugin.
Related Issues (20)
- Very long project rebuild HOT 1
- Error RSPack with pug-plugin HOT 1
- i18next doesn't work after pug-plugin update to 5.0.0 (windows only) HOT 4
- How to complie the pug file to template function on pug-plugin v5 like pug-plugin v4? HOT 9
- How do I connect modules so that I can use them, instead of getting the resolved path to this module? HOT 2
- Some difficult questions (SCSS import as string)... HOT 7
- [FEATURE REQUEST] Preload support for font image audio video HOT 4
- Require manifest.json file HOT 3
- How to use Tailwind CSS with pug-plugin HOT 5
- Unexpected token '.' in Plugin.js issue. Can't compile my files HOT 1
- When connecting one page to js, a number is substituted HOT 4
- How to set the correct path to files connected via url in scss with Output Path option HOT 3
- Compilation fail on module contents change HOT 5
- The handling of @import at-rules in CSS is not supported. HOT 4
- [FEATURE REQUEST] Add ability to disable scripts compiling. HOT 2
- Failed to generate common named chunk with enabled pug plugin HOT 4
- Invalid url when using full path "publicPath" option HOT 5
- How to dynamically substitute a path in pug include HOT 1
- Issue with imports in required scripts HOT 7
- handling pug in webpack setupMiddlewares
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pug-plugin.